1. 写入缓存:建立文件夹,把list集合里面的数组转换为JSON数组,存入文件夹 2. 读取缓存:把JSON数组从文件夹里面读取出来,然后放入list集合,返回list集合 private final static File filefolder=new File("/sdcard/myData"); private final static File filename=new File("/sdcard/myData/tem.txt"); public static boolean writeCache(List list) { if(!filefolder.exists()) filefolder.mkdirs(); try { JSONArray array=new JSONArray(); for(int i=0;ireadCache() throws JSONException,IOException { if(!filefolder.exists()) filefolder.mkdir(); List list=new ArrayList(); if(filename.exists()) { FileInputStream in=new FileInputStream(filename); String line=null; StringBuffer sb=new StringBuffer(""); BufferedReader br=new BufferedReader(new InputStreamReader(in)); while((line=br.readLine())!=null) sb.append(line); br.close(); in.close(); JSONArray array=new JSONArray(sb.toString()); for(int i=0;i