-1

I have an array `mydata' of 3 numbers.

x = number of trials

y = number of successes

z = (x/y)*100

But when I quit my app, this data is wiped and all my numbers are gone.

How do I save this information in a file and call it back upon restarting the app so that the data is always as I left it?

Mr.NoName
  • 125
  • 4
  • 13

3 Answers3

2

Store your array data while closing in SharedPreferences. While logging back up/opening up, you can fetch the data from the SharedPreference, it will be there.

SharedPreferences tutorial

Hope it helps. Cheers!

O_o
  • 1,103
  • 11
  • 36
2

you variables will be wiped becuase whenever your app is killed all of its data is wiped from RAM. you need to use 'sharedPreferences' to store your little datas like this in storage. see link below:

How to use SharedPreferences in Android to store, fetch and edit values

Community
  • 1
  • 1
Amir Ziarati
  • 14,248
  • 11
  • 47
  • 52
0

Read Storage Options for information about storing data permanently for your app.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268