Reputation: 3464
Okay, so I have this file system using serializer to save an arraylist into a JSON file. The JSON file is created in the code. If I turn off the power, the data and file is erased. So if I want the data saved and reloaded even when the android phone is restarted. Which way to save data is the best? Can we use a JSON file to do that?
Upvotes: 1
Views: 1981
Reputation: 926
You can use SharedPreferences
or saving it to external storage
orsaving it to SQLliteDB
you can convert the JSONObject
to a string and save by using one of the above methods.
for examples on using different storage options please refer Storage options
Upvotes: 1
Reputation: 157467
You can save in a file into the sdcard
or you can use the SharedPreferences
. In fact the toString()
of a JSONObject
returns a String that represent the json itself
Upvotes: 2