How to use Sharedpreferences access modes?

Asked

Viewed 61 times

0

When we use Sharedpreferences, we have for example:

SharedPreferences prefencias = getSharedPreferences(nome, modo);

Where "name" is the name of the preference and "mode" indicates the permission that can be:

MODE_PRIVATE
MODE_WORLD_REABLE
MODE_WORLD_WRITE_WRITEABLE

What does each of these modes of access mean? How to use them properly? In what situations?

1 answer

2


MODE_PRIVATE

Only your application can have access to data preferably.

MODE_WORLD_REABLE

All applications on the device can read your data preferably but cannot edit, save or write to the data.

MODE_WORLD_WRITE_WRITEABLE

All apps on your device can read and write to your preferred data.

In most cases we use MODE_PRIVATE only in very specific cases you will use the other two.

https://developer.android.com/training/data-storage/shared-preferences

Browser other questions tagged

You are not signed in. Login or sign up in order to post.