Sharing settings or internal file storage - Any memory issue?

I want to know what is best for storage purposes: General preferences or internal file storage. Which is faster? Are there any memory problems with any of them?

Thanks,

+4
source share
4 answers
  • SharedPreference: Store private primitive data in key-value pairs. (For storing small records / data)
  • Internal storage . Store personal data in the device’s memory. (To store large data sets)

Read more about storage options here: Storage Options

I saw a problem about general preferences.

Question: Whenever you encounter a Force close / app crash when using SharedPreference, SharedPreference will be null. You can read more about this here: General preferences reset when the application is forcibly closed or reset

+10
source

Read the Android doc related to data storage.

If you want to keep very small values, you can choose SharedPrefrence.

+1
source

So, Shared preferences also last saved in internal file storage .

the Share preferences as a key-value pair, it stores data in memory and, finally, is stored in the internal file storage by the system.

if you want to access the value often, you can use Shared preferences .

If the data structure is small and not complicated, you can direct use Share preferences

if you just want to save the data, and a lot of memory space will be taken for the data, you can simply use the file to save.

+1
source

It totally depends on what you like: if you have a fairly small number of key-value pairs, go with Shared Preferences. If you have more data, use the file as the general preferences will be stored in memory after they are used first. So it’s a bad idea to store a large amount of data in it; -).

0
source

All Articles