I have developed an app, and right now I have an arraylist of Profiles (Custom class) that I would like to be saved whenever a new profile is added to the app. So, whenever a user adds a profile, after closing and re-opening the app, the profiles are still there. How can I do this?
Asked
Active
Viewed 199 times
0
-
1Are you asking how to make data persist from one session to another i.e. turning the app on and off? If yes, you'll need to incorporate some type of storage such as Sqlite or the local storage available on the device, like shared preferences. See here: https://developer.android.com/guide/topics/data/data-storage.html – Steve Dec 30 '17 at 23:54
-
I prefer to use local storage using Shared Preferences, however, all the solutions I found where for storing arraylist of strings and NOT a custom class like my case. – Abdane Dec 31 '17 at 00:27
-
for saving arrayList check this https://stackoverflow.com/a/11050845/7569106 – Mohamed Embaby Dec 31 '17 at 00:32
-
@MohamedEmbaby as I have mentioned, this solution works for ArrayList of type string, not a custom object. – Abdane Dec 31 '17 at 01:06
-
As far as I know there is no such thing. However its better to make some adjustment to ur app and use Database like sqlite – Mohamed Embaby Dec 31 '17 at 01:22
-
Hmm, I see, ill keep the question open for other suggestions, until then, ill learn how to use SQLite to solve me issue. Thanks! – Abdane Dec 31 '17 at 01:31