Reputation: 1184
I am developing an android app in phonegap. I have to store a json data that should be secured. The json contains authentication keys and tokens so it should not expose. So I cant store it to any kind of javascript local storages. Is there any other way to save data securely ?
Upvotes: 4
Views: 778
Reputation: 2031
Better to use android Shared preference, you can set it by plugin. Here are the steps :
1 In your javascript add this
function storeJSON(JSON_String){
cordova.exec(function() {
//CALLBACK SUCCESS
}, function(error) {
//ERROR CALLBACK
}, "YOUR_CUSTOM_CLASS", [JSON_String,"SET"]);
}
function getJSON(){
cordova.exec(function(Json) {
//CALLBACK SUCCESS
alert(Json);
}, function(error) {
//ERROR CALLBACK
}, "YOUR_CUSTOM_CLASS", ["","GET"]);
}
2 Create Java class YOUR_CUSTOM_CLASS. Download
3 In config.xml add this
<feature name="YOUR_CUSTOM_CLASS">
<param name="android-package" value="yourpackage.YOUR_CUSTOM_CLASS" />
</feature>
Upvotes: 5
Reputation: 3207
Use native storage methods like sqlite DB thats better, check https://github.com/lite4cordova/Cordova-SQLitePlugin - Sqlite plugin for Android
Upvotes: 0