嗨,我想使用缓存(如 kinvey API)在 android 中实现离线存储?任何人都可以分享相同的逐步实现吗?我搜索了很多,但没有得到太多关于 Android 缓存的信息。
问问题
379 次
1 回答
0
Cache cache = AppController.getInstance().getRequestQueue().getCache();
Cache.Entry entry = cache.get(API);
if (entry != null) {
try {
String data = new String(entry.data, "UTF-8");
JSONObject jobj = new JSONObject(data);
FileWriter file = new FileWriter(cxt.getFilesDir().getPath() + "/" + fileName);
String jsonString = jobj.toString();
file.write(jsonString);
file.flush();
file.close();
// prepareListData(jobj);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
于 2016-08-08T10:17:29.513 回答