I doing a Android project wich has two Activities. Both of these Activities are Listactivities.
The first Activity is the entry point of the app, in that list it’s possible to create new names that are added to the list. I want to store these names in either a shared preference or to a file. But I don’t know how to do it. I’ve tried both but with no success.
When a item in this list is pressed an instance of the other activity should be shown and only the list items that belong to this choice should be visible.
To make it easier to understand you can think of it as a contacts app.
The data from both the first and the other list must be saved in some way.
How do I do that? Should I use shared preferences or internal storage?
And how can I do to make the second listview display the right data?
Thanks! /Tim
I used an SQLite database to do this.
So in the first activity, I query the SQLite db and get a
cursorobject back, which I can plug into acursorAdapterwhich then is used as the adapter for the list activity.In the
cursorAdapter, for each item on the list, I set anonClickListener, which when clicked, launches the new activity and adds the list item to the new activity’sBundleFinally, I get the list item from the
Bundlein the new activity and use it to query the SQLite db again, and use that to produce the second list just like I did with the firsthttp://developer.android.com/reference/android/widget/CursorAdapter.html
Shared preferences is just for small stuff that uses little data and is only needed occasionally, such as preferences / settings