Home » Android » android – Major Difference between sharedpreference and internal file storage

android – Major Difference between sharedpreference and internal file storage

Posted by: admin June 15, 2020 Leave a comment


I want to know which is better for storage purpose:
Shared preferences or internal file storage.
Which is faster?
Is there any memory issue with anyone of them?


How to&Answers:
  • SharedPreference: Store private primitive data in key-value pairs. (To store small entries/data)
  • Internal Storage: Store private data on the device memory. (To store large datasets)

More about Storage Options here: Storage Options

I have seen an issue about shared preference.

Whenever you face Force close/app crash while using SharedPreference, SharedPreference will be null. Here you can read more about it: Shared Preferences reset when the app is force closed or crashes


Well, the Shared preferences also saved in the internal file storage at last.

the Share preferences like the key-value pair, it keep the data in memory, and saved to the internal file storage by system at last.

if you want to access the value frequently, you can use Shared

if you data structure is small and not complicated, you can directed
use Share preferences

if you just want to save data, and the data is will taken many memory
space, you can just use file to save.


Please read Android document related to data storage.

If you want to store very small values then you can opt for SharedPrefrence.


It totally depends on what you like to do: If you have a rather small amount of key-value pairs go with the Shared Preferences. If you have a larger amount of data use a file as the Shared Preferences will be hold in memory after they where first used. So it’s a bad idea to store large amount of data in it ;-).