About maps and activities

engvidal

Member
Licensed User
Longtime User
Dear Friends.

I have an app with 2 activities.

The main has a button that calls the second activity and a button that send an email (it runs ok).

The second activity has 3 edittexts and 2 buttons (save and restore).
I write to the 3 edittext and then save the edittexts to the map. The button restore retrieves the 3 pairs of key/values to the editexts (it runs ok)
I have too a button to close activity and return to main.

Problems:
1) After returning to the main, if I call the second activity again the values at the map are lost.

2) How can I use these pairs of values at the main activity ?

Vidal
 
Can you post your code? What you may want to do is Dim your map AND initialize it in your Main activity under Process globals (only once)
 
Upvote 0
source

Hi

I made a more simple app

Just one activity, that saves and then reads the maps values.
It runs ok, BUT if the app is closed, when it is called again, the map values are lost.
 

Attachments

Upvote 0
This is because you are not loading the file. Remember, when you are saving persistent data to disk, you will need to load the file when the app first starts. Otherwise how does your app know the file exists? See the attached modified code.
 

Attachments

Upvote 0
Maps

Dear JonPM

If I did understand, when using 2 or more activities, I need only read the file from memory at the start of my app, and at the other activities just initialize the map, ok ?

Tomorrow I will try it.

Menu Thanks

Vidal
:sign0098:
 
Upvote 0
Maps and multiple activities

Hi JonPM

Now it is running ok. Thank You very much.

The error was that after making any changes at the map, when returning to the first activity I were not reading the file again, just trying to read the values.

I thought that the map1.get function would read it in the file,but it reads 'the file that is at the memory'.

Vidal
 
Upvote 0

Similar Threads

Replies
36
Views
136K
Replies
16
Views
13K
  • Locked
  • Article Article
Android Tutorial Google Maps
Replies
192
Views
206K
Back
Top