如何保存JSON数组到Android内部存储 [英] how to save json array to android internal storage
问题描述
所以,我的工作这样一个项目的 http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/ 这让我显示我的数据库的价值,以我的Android应用程序的GUI。
So I'm working on a project like this http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/ which let's me to display my database's values to my android application GUI.
我要救我需要在Android内部存储的数据库值,所以我可以访问它,即使我的应用程序没有连接到服务器。任何帮助?
I need to save the database values I need to the android internal storage so I can access it even if my application is not connected to the server. Any help?
感谢您
推荐答案
您可以写完整的JSON作为字符串中的共享prefernces,然后得到它,分析它的图形用户界面,显示即使在设备脱机:
You can write whole json as string in shared prefernces, and then get it and parse it to display in GUI even when device is offline:
String str = json.toString();
SharedPreferences sharedPref = getSharedPreferences( "appData", Context.MODE_WORLD_WRITEABLE );
SharedPreferences.Editor prefEditor = getSharedPreferences( "appData", Context.MODE_WORLD_WRITEABLE ).edit();
prefEditor.putString( "json", str );
prefEditor.commit();
这篇关于如何保存JSON数组到Android内部存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!