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
 

JonPM

Well-Known Member
Licensed User
Longtime User
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

engvidal

Member
Licensed User
Longtime User
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

  • maps_test.zip
    7.8 KB · Views: 130
Upvote 0

JonPM

Well-Known Member
Licensed User
Longtime User
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

  • Maps_teste.zip
    7.9 KB · Views: 151
Upvote 0

engvidal

Member
Licensed User
Longtime User
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

engvidal

Member
Licensed User
Longtime User
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
Cookies are required to use this site. You must accept them to continue using the site. Learn more…