2

What are the disadvantages of using too much SharedPreferences on android?

LuxuryMode
  • 33,401
  • 34
  • 117
  • 188
wesdfgfgd
  • 683
  • 1
  • 13
  • 26

5 Answers5

2

Shared preference are for quick access and are loaded in the memory for fast access along with the application...so if you try to store large amount of data in shared preference...it is going to cause some more usage of critical memory of your app(and i guess if too big to store in memory some swapping would happen causing performance impacts).Better to use DB/file system/web server for huge data....by storing small quantities of information that are very often accessed by the app you can in-fact increase your application performance.

Navin Ilavarasan
  • 1,271
  • 11
  • 15
1

user can clear data which is stored in Shared preference at any time. this is the major drawback of Shared preference.

Rohit Jain
  • 229
  • 1
  • 4
  • 7
1

If you try to do anything complicated with SharedPreferences quickly becomes very tedious; you can only store primitive types and it's a simple key/value system. So, there are no disadvantages per se, but SharedPreferences are meant for lightweight storage of simple data.

LuxuryMode
  • 33,401
  • 34
  • 117
  • 188
  • Question: If I were to say I would load 500kb worth in a string would it cause a issues to the app?. – wesdfgfgd Jan 26 '12 at 21:36
  • not necessarily, but like i said, you shouldnt be using sharedpreferences for tons of stuff...that's screaming to you that you need to use a database or some other manner of persisting data. – LuxuryMode Jan 26 '12 at 21:37
1

You should only use SharedPreferences to store small bits of data related to user configuration. It can only store basic data types, so if you have more complex bits of information, you should probably switch to another mechanism.

One convenient feature of SharedPreferences is that you can share data between two applications using it; so if you have two applications that have to share user preferences with each other, using SharedPreferences might be a convenient choice.

Also, you should not store large amounts of data in SharedPreferences; it's not made for that. Instead, use an SQLite database(1) for a more robust solution.

(1) http://developer.android.com/reference/android/database/sqlite/package-summary.html

Bruno Oliveira
  • 5,056
  • 18
  • 24
0

first point to be considered is shared preferences are non-volatile data. So they are stored as key-value pairs as your application data. So, using them extensively in your app might become complicated for you. And, coming to process throughput, it don't effect your app speed because these are stored in/as secondary storage.

Anuroop Pendela
  • 147
  • 1
  • 8