一种方法是使用共享首选项存储JSON字符串,并在需要时进行更新。
要存储数据:
SharedPreferences settings = getApplicationContext().getSharedPreferences("PREF_NAME", MODE_PRIVATE);SharedPreferences.Editor editor = settings.edit();editor.putString("strJSON", "" + strJSONfromServer);editor.commit();要检索数据:
SharedPreferences settings = getApplicationContext().getSharedPreferences("PREF_NAME", MODE_PRIVATE);String strData = settings.getString("strJSON", "");清除数据:
SharedPreferences settings = getApplicationContext().getSharedPreferences("PREF_NAME",MODE_PRIVATE);SharedPreferences.Editor editor = settings.edit();editor.remove("strJSON");editor.commit();


