Simple react native plugin for accessing Android SharedPreferences.
getSharedPreferences should be called with a proper preferences file name. So, essentially every SharedPreferences JS Object is bound with a single preferences file.
After getting the instance, methods like putString, getString shall be called as given in the Usage section.
Since this plugin simply wraps the Android SharedPreferences, all the thread safety and performance guarantees will be intact.
$ npm install react-native-android-shared-preferences --save
Mostly automatic installation
$ react-native link react-native-android-shared-preferences
- Open up
import com.makemytrip.sharedpref.RNSharedPreferencesPackage;to the imports at the top of the file
new RNSharedPreferencesPackage()to the list returned by the
- Append the following lines to
include ':react-native-android-shared-preferences' project(':react-native-android-shared-preferences').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-android-shared-preferences/android')
- Insert the following lines inside the dependencies block in
;var sharedPreferences = RNSharedPreferences;sharedPreferences;console;