-1

I the last i've been creating some sort of a "contacts" app. In the main activity i have created a listview that syncronises itself with an ArrayList of strings(names). To add names to the the listview i created another activity. I have managed to get the two activities to talk to each other(send the name(the string) to the "list" activity), but i am struggeling to find a way to save the the ArrayList.

The problem is that every time the "list" activity is leaved and then resumed all the old content disappears.

So, i guess i need a good way to save an ArrayList?

2 Answers2

0

You can start from here:

Storage Options

Saving Data

Also, I recommend to use JSON, if you decide to store your list in file.

0

You can use SharedPreferences class ,Internal Storage ,External storage or SQLite.

This is good tutorial for SQLite: http://www.androidhive.info/2011/11/android-sqlite-database-tutorial/

This is how to use SharedPreferences: http://developer.android.com/training/basics/data-storage/shared-preferences.html

This is how to write a file in external storage: Write a file in external storage in Android

This is how to write a file in internal storage:How to create a file on Android Internal Storage?

Don't forget permission for external and internal storage.

I mean it's better to use SQLite for data like a contact.

Community
  • 1
  • 1
MilanNz
  • 1,323
  • 3
  • 12
  • 29