Android之assets资源
assets目录下存放的原生资源文件,通过getAssets()方法获取. 使用: InputStreaminputStream;try{ inputStream=getAssets().open("data/chat.isp"); Stringjson=StringUtil.readTextFile(inputStream); JSONArrayarray=newJSONArray(json); backModelresult=null;for(inti=0;i<array.length();i++){ result=newbackModel(); result.setTime(array.getJSONObject(i).getString("time")); result.setContent(array.getJSONObject(i).getString("content")); backModels.add(result); } }catch(IOExceptione){ e.printStackTrace(); }catch(JSONExceptione){ 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 ,如需转载请自行联系原作者