When i write anything into shared preferences it overwrites the previous value, how can i continuously inject values in preferences and fetch it out all at once like an array? I do not want to use database for this operation.
Thanks
When i write anything into shared preferences it overwrites the previous value, how can i continuously inject values in preferences and fetch it out all at once like an array? I do not want to use database for this operation.
Thanks
You can use JSON as @CommonsWare points out to store your data in SharedPreferences. I have such an answer that using GSON here:
Though not ideal, if you want to use Preferences only, You can store String in preferences. When next value is to be added, retrive the old one add 'comma' and new value. Whenever you want to use these values, use StringTokeniser. Tokenise elements by 'comma' character.