こんにちは、JSON フィードが Web サイトから JSON オブジェクトに渡されました。JSONObject を .JSON ファイルに書き込んで、再度取得し、その中の値を編集できるようにすることです。茶色"。色を赤に変更してから、JSON ファイルに再度保存するにはどうすればよいですか?
これまでのところ、私が試したことはここにありますが、ファイルの書き込みに行き詰まっています
私のグローバルアクションで私が持っている
public final static void writeDataToFile(Context activityContext, String writableString, String fileName){
FileOutputStream fos=null;
try {
fos=activityContext.openFileOutput("/assets/files/"+ fileName, 0);
fos.write(writableString.getBytes());
} catch (FileNotFoundException e) {
Log.e("CreateFile", e.getLocalizedMessage());
}
catch (IOException e) {
Log.e("CreateFile", e.getLocalizedMessage());
}
finally{
if(fos!=null){
try {
// drain the stream
fos.flush();
fos.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
そして私の活動で
public void apiNetworkCallResponse(){
Log.v("loginForm", "11111111111");
Log.v("loginForm", "apiNetworkCallResponse = " + responseJSON);
String writableString = responseJSON.toString();
GlobalActions.writeDataToFile(this, writableString, "mynetwork.json");
}
エラーはこちら
02-15 15:43:59.209: E/AndroidRuntime(7525): java.lang.IllegalArgumentException: File /assets/files/mynetwork.json contains a path separator