I have looked around but have not been able to find anything related. I have 3 Lists (week, day, period) I need to write them to a file so that they are not deleted when the app is closed. How would I write these lists to a file and then when the app is open read them back into a List as they were before. Not sure if this is a stupid question.
Asked
Active
Viewed 49 times
1
-
possible duplicate of [Making data persistent in android](http://stackoverflow.com/questions/3310066/making-data-persistent-in-android) – abhi Jan 22 '14 at 19:47
-
If the data is not too big you can easily store them using Shared Preferences. – Rohan Kandwal Jan 22 '14 at 20:50
1 Answers
0
You can find some examples in the android doc.
Basically, you can use File like in Java, for example to write (from android doc):
String FILENAME = "hello_file";
String string = "hello world!";
FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
fos.write(string.getBytes());
fos.close();

Thierry
- 5,133
- 3
- 25
- 30