Search code examples
androidthread-safetydata-storage

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


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


Solution

  • 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