assets目录下存放的原生资源文件,通过getAssets()方法获取.
使用:
InputStream inputStream; try { inputStream = getAssets().open("data/chat.isp"); String json = StringUtil.readTextFile(inputStream); JSONArray array = new JSONArray(json); backModel result = null; for (int i = 0; i < array.length(); i++) { result = new backModel(); result.setTime(array.getJSONObject(i).getString("time")); result.setContent(array.getJSONObject(i).getString("content")); backModels.add(result); } } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); }
其中数据存在于assets\data\chat.isp文件中:
[{"time":"14:25:29","content":"在么?,","type":"1"},{"time":"14:26:18","content":"嗯,在的,","type":"2"}]
本文转自xmgdc51CTO博客,原文链接:http://blog.51cto.com/12953214/1941206 ,如需转载请自行联系原作者