0

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 ?)

Jimmy
  • 10,427
  • 18
  • 67
  • 122

2 Answers2

0

You could use sqlite tables for this.

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

Joel G Mathew
  • 7,561
  • 15
  • 54
  • 86
  • i dont think sqlite is the right thing to do, it feels that its unnecessary overhead for only one column. – Jimmy Jan 10 '12 at 05:44
0

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
Shailendra Singh Rajawat
  • 8,172
  • 3
  • 35
  • 40
  • 1- You cant put an array in shared preferences, and saving Sets only introduced in resent API (11 i think) which is not supported by most devices. 2- im thinking of doing so, but do i save it in json file or serialize it ? 3- still cant think of it as good idea since its a little bit overhead for one column – Jimmy Jan 10 '12 at 05:54
  • 1 ) no , its since API level 1 , so you should never think so 3) Agree . – Shailendra Singh Rajawat Jan 10 '12 at 05:58
  • if you mean getStringSet it's since API 11 (search the page for Since: API Level 11) http://developer.android.com/reference/android/content/SharedPreferences.html and look here http://stackoverflow.com/questions/5843334/sharedpreferences-getstringset-not-found – Jimmy Jan 10 '12 at 06:07