【发布时间】:2015-03-24 10:04:40
【问题描述】:
我在 PlayStore 中有我的应用程序。当我使用新导出的 apk 更新我的应用程序时,SharedPreference 键正在更改。您可以通过查看下面给出的 json 字符串来理解它。
我正在将一个对象保存在共享首选项中,如下所示。
-
在 SharedPreference 中保存用户详细信息。
Gson gson = new Gson(); String json = gson.toJson(user); prefsEditor.putString("user", json); prefsEditor.commit(); -
从 sharedPrefernce 中获取详细信息
Gson gson = new Gson(); String json = myPref.getString("user", null); Log.v(MainActivity.TAG, "Json == "+json); user = gson.fromJson(json, User.class);
请查看我正在打印的 json,键已更改为 'a'、'b' 等。
当我正常运行时,JSON 是
Json == {"accessToken":"12345678","country":"India","countryCode":"91","email":"","firstName":"Aneesh","lastName":"Kamalone","nickName":"Kamalone","notificationId":"","phoneNumber":"******","profilePic":"","uniqueId":"","userId":"*****","userLatitude":14.9,"userLogitude":79.6}当我用以前的版本更新时,json 是
Json == {"a":"****","b":"Aneesh","c":"Kamalone","d":"Kamalone","e":"**********","f":"","g":"APA91bElQulddjH6xSR0WH8nfBGcFIbn-sRe-ChkhIx1c6Il05_wwGrTLm1QDNsr6TtaG1bIrICmXKhK1I8ZVzo0cqvwPWSj4NrxJKyzTsdPpNlizmGMaJfMWj_rjteP6yNoRFeDAZYfTCyhx-7WUAmTT2rX0q1S6Q","h":"","i":"12345678","j":"India","k":"91","l":14.9,"m":79.6,"n":""}
【问题讨论】:
标签: android json sharedpreferences apk