如何安全地存储在PhoneGap的Android的一个JSON数据? [英] How to store a json data securely in phonegap android?
本文介绍了如何安全地存储在PhoneGap的Android的一个JSON数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我开发的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的共享preference,您可以通过插件的设置。 具体操作步骤如下:
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。 下载
3 config.xml中添加此
3 In config.xml add this
<feature name="YOUR_CUSTOM_CLASS">
<param name="android-package" value="yourpackage.YOUR_CUSTOM_CLASS" />
</feature>
这篇关于如何安全地存储在PhoneGap的Android的一个JSON数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文