-6

This seems to be a common question, but i am unable to find out a straight away answer.

I get JSONObject from server, each activity needs to access it and get some data from it, that's the reason i am more concerned about the performance here.

This is what i do. Following operation runs for each activity.

DatabaseHandler db = new DatabaseHandler(context);
dataObject = db.getAllData();
jsonObject = new JSONObject(dataObject );
value = jsonObject.optString(key);

The data is pretty straight forward, its a simple JsonObject, i can also put this in sharedPreference, but before moving to sharedPreference, i want to be sure that sharedPreference are faster than sqlite database, or moving to sharedPreference can give me performance improvement.

dev90
  • 7,187
  • 15
  • 80
  • 153
  • 1
    Yes I think it will give you a better performance and async handling of saving data with .apply() instead of .commit() the only perk I see is the quantity of data you store in sharedPreferences – Reda Jan 06 '18 at 19:57

1 Answers1

-1

If your data Are low and only type text, surely the variable is the best option

Otherwise, if your data is large and are many and different, you should use powerful Android databases like : MySqlite , Realm , ...

Majid Ahmadi Jebeli
  • 517
  • 1
  • 6
  • 22