How can i store an array list of hashmap in shared preferences android?Any help would be appreciated.
-
1you can't. You can store only primitive types.. Go for sqlite. – Andro Selva Aug 20 '13 at 05:48
3 Answers
After API 11, Shared Preferences accepts sets such as ArrayLists with HashMaps embedded in them.
Please go through this link for a thorough walk-through about saving ArrayLists to Shared Preferences:
Save ArrayList to SharedPreferences
It will solve your problem.
P.S: The sole purpose of Shared Preferences is to save the values that are less frequently accessed and that are not too Large (like the settings of Application). Therefore, if you have Data Sets that are large in sizes and are not related to to the Application's Settings, then you should go for a proper SQLite DB.
EDIT:
Other Options available for storing the Data in ArrayList is to use a proper SQLite Database.
Here is the link that contains code and information related to Storing and Retrieving ArrayLists from SQLite Database.
I hope this solves your problem.

- 1
- 1

- 6,684
- 7
- 33
- 58
-
Thanks for your response.Can u please tel me is there any other storage option to come out from this issue than shared preferences. – Kirthiga Aug 20 '13 at 06:17
In order to store Object type into the SharedPrefrence.
You can refer to below post having similar issue.
Download gson-1.7.1.jar from this link: GsonLibJar

- 1
- 1

- 8,914
- 1
- 25
- 33