// 把JSON写到文件中 public void saveCrimes(ArrayList<Crime> crimes) throws JSONException, IOException { // build an array in JSON JSONArray array = new JSONArray(); for (Crime c : crimes) array.put(c.toJSON()); // write the file to disk Writer writer = null; try { OutputStream out = mContext.openFileOutput(mFilename, Context.MODE_PRIVATE); writer = new OutputStreamWriter(out); writer.write(array.toString()); } finally { if (writer != null) writer.close(); } }