jpgerb
jpgerb

Reputation: 1120

Caching and persisting data

I want to do 2 things. I want to be able to cache data so that I can "save" variables when I move from 1 activity to another where the variables of the first are not needed in the second.

I also want to be able to formally save the data upon the file exiting. Unfortunately my issue is, I can't find any documentation on how to complete these.

There are 4 strings (listed below) that I want to save long term as well as temporarily while moving within the activities.

String[] name
Double[] amount
Double[] rate
Integer[] term

Each String has room for 10 different pieces of data. The data will be sorted, and needs to be saved while I go to another activity which new data is input and carried to my first activity to be placed in these strings, and finally - saved.

Please provide suggestions or documentation links so I can learn how to do this.

Upvotes: 0

Views: 78

Answers (1)

Jans
Jans

Reputation: 11250

Your question look a little confusing, but if you want to pass between activity1 to activity2 and preserve variable that you keep in activity1, you don't need to make nothing because androdi preserve that state, when you go back to activity1 from activity2.Yoou can refer Saving variables state post for case y,ou want to save state in configuration changes. Passing activity data to pass data between activities and for saving in file you have two options. Preferences and Saving in File.

Upvotes: 1

Related Questions