Luis Neves
Luis Neves

Reputation: 1077

Android - Download JSON data and save to shared preferences

I'm reading JSON data from a PHP Service and everytime the version of that JSON changes, I want to store it on Android (replace the old data with the new one), the JSON is used only for fill a Spinner.

My question is: - The JSON has 36KB, is OK to store it on Shared Preferences has a String or should I use SQLite to store it?

There will be one update per month

Example of my data : http://zimp.hugo.webe.pt/api/occupations/list

Upvotes: 1

Views: 1505

Answers (4)

jeet
jeet

Reputation: 29199

if its a json String, having many records, values, then I would recommend to parse this string into records, and then save these records to sqlite, so that you wont need to parse this string again, and again, un-necessarily. otherwise, there isn't any issue in saving string into sharedpreferences.

According to your data, you should opt for SQLite.

Upvotes: 3

Chintan Khetiya
Chintan Khetiya

Reputation: 16152

It's Depend on your data.

  • If your data should be dynamic and change frequently then you must use JOSN.
  • If YOUR data is not Not regular update and not a large size then store in shared preferance.
  • if your data large then store in database.

Now you have to decide which one you select.

Upvotes: 0

Kalpesh Lakhani
Kalpesh Lakhani

Reputation: 993

Not a problem to save in shared preference..but keep in mind that SP mostly saves primitive data types in key value pair...and not an issue of 36kb in your case.:)

Upvotes: 0

Anders Metnik
Anders Metnik

Reputation: 6237

It's fine to store it in shared preferences.

Upvotes: 1

Related Questions