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 ?
Asked
Active
Viewed 770 times
2 Answers
5
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>

Arjun T Raj
- 3,187
- 1
- 21
- 44

manukv
- 2,031
- 18
- 30
-
Hi manu.. thanks for ur answer, I want to know that where it going to store and how can I erase it after my usage? – LeNI Apr 02 '14 at 10:02
-
1It stores in application file system. If you need to delete it, just pass a null value to storeJSON() function. simply :) – manukv Apr 02 '14 at 10:07
0
Use native storage methods like sqlite DB thats better, check https://github.com/lite4cordova/Cordova-SQLitePlugin - Sqlite plugin for Android

Arjun T Raj
- 3,187
- 1
- 21
- 44