How could i save a unique list of values in Android?

199 Views Asked by At

I have a list of unique values, lets say for example city names (Japan, Paris) and it could be modified by the application later to be (Paris, New York ). what i need is a away to save them and then retrive them. How could this be done and how could i insure if its thread/process safe? (Set Serialization, JSON file, Preferences ?)

2

There are 2 best solutions below

3
On BEST ANSWER

all you need is a persistant storage of data . so use any of these approches:

  1. save an array of citynames into shared preferences and modify whenvey you need so , no idea whether its thread safe .
  2. us internal/external file to save data , here you can make it thread safe by java multithreading
  3. use sqlite database , thread safe
1
On

You could use sqlite tables for this.

This page describes an example of how to do this. http://www.screaming-penguin.com/node/7742