如何存储json数据安全在phonegap android? [英] How to store a json data securely in phonegap android?
本文介绍了如何存储json数据安全在phonegap android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在phonegap开发一个Android应用程序。我必须存储一个应该安全的json数据。 json包含身份验证密钥和令牌,因此它不应该公开。所以我不能将它存储到任何类型的JavaScript本地存储。有没有其他方法来安全保存数据?
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 ?
推荐答案
更好地使用Android共享首选项,
以下是步骤:
Better to use android Shared preference, you can set it by plugin. Here are the steps :
1在您的javascript中添加
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创建Java类YOUR_CUSTOM_CLASS。 下载
2 Create Java class YOUR_CUSTOM_CLASS. Download
3在config.xml中添加此
3 In config.xml add this
<feature name="YOUR_CUSTOM_CLASS">
<param name="android-package" value="yourpackage.YOUR_CUSTOM_CLASS" />
</feature>
这篇关于如何存储json数据安全在phonegap android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文