I’m developing an android app where the user will brows different activities. I have a RecentActivity.java class that will show an empty listview and every time the user enters other activities, I add each activity to the listview in RecentActivity.java . But when I exit the app and open other apps the RecentActivity loses the content were stored in the listview, so I wanted to keep its data all the time. Thanks I will appreciate your suggestions.
Asked
Active
Viewed 67 times
2 Answers
1
You can create an SQLite database to store your browsing history, here is a tutorial of SQLite usage in Android: Android SQLite tutorial

Max Rasguido
- 457
- 6
- 27
-
Hi, thanks I’ve been playing with SQLite to add a search feature but with no success, I’ll check this tutorial out. But in the mean while till I understand SQLite, is there a way to keep an activity on its state all the time even after exiting the app? – fullmoon Aug 26 '12 at 01:30
-
This may be helpful [Persistent Data](http://stackoverflow.com/questions/3310066/making-data-persistent-in-android) – Max Rasguido Aug 27 '12 at 00:23
0
There are a number of different Storage Options but which to use depends on what you are storing.
"State" is rather vague, you can use shared preferences if you are storing primitive data
You can use the JSON format and something like the GSON library if you want to store classes but don't need query capability (GSON library makes it very easy to use in most cases) and then write the results either external or internal storage (up to you)
SQLite in my opinion would be overkill for simple storage of state, but then again not exactly sure what you are trying to store or how you are trying to retrieve it.

Idistic
- 6,281
- 2
- 28
- 38
-
Appreciate your reply, I have a RecentActivity.java class that will show an empty listview and every time the user enters an other activities, I add that activity to the listview in RecentActivity.java – fullmoon Aug 26 '12 at 04:41
-
Well if you want to keep an array of class names then probably go with JSON/GSON you can simply save the array to storage, then read it back in have done something similar many times. – Idistic Aug 26 '12 at 17:05