This plugin allows you to store information ( like username ). It uses Preferences in Android and NSUserDefaults in iPhone.
a) Works with PhoneGap >= 3.0.
b) Supported value types : String, int, boolean
- Add the following xml to your config.xml:
<feature name="MyStore"> <param name="ios-package" value="AppPreferences" /> </feature>
- Grab a copy of plugins.js, add it to your project and reference it in index.html:
<script type="text/javascript" src=“js/plugins.js"></script>
- Download the source files for iOS and copy them to your project.
Copy AppPreferences.h and AppPreferences.m to platforms/ios/<ProjectName>/Plugins
- Click your project in Xcode, clean and build.
- Add the following xml to your config.xml:
<feature name="MyStore">
<param name="android-package" value="com.vamsi.plugins.AppPreferences"/>
</feature>
- Grab a copy of plugins.js, add it to your project and reference it in index.html:
<script type="text/javascript" src=“js/plugins.js"></script>
- Download the source files for Android and copy them to your project.
Android: Copy AppPreferences.java to platforms/android/src/com/vamsi/plugins (create the folders/packages).
var MyStore = cordova.require("com.vamsi.plugins.preferences”);
function success (value) {alert('success'); }
function failure (error) { alert('failure');}
MyStore.save("userName","test","string",success,failure);
MyStore.fetch("userName",success,failure);
MyStore.remove("userName",success,failure);