で開いたときにJSONファイルが空になります。ファイルが空です...コンテンツが表示されません...なぜですか?スマートフォン<code>JSON VIEWER</code>のアプリで<code>JSON file</code>を開くと、アプリケーションjsonビューア
は今、私はあなたに私は、ファイルjson
を保存する方法を私のコードを表示....事前みんなで
ありがとう!
public String showResult(View v) throws IOException {
String result = "";
JsonObject json = new JsonObject();
for (Planet p : plAdapter.getBox()) {
if (p.isSelected()){
json.put("name",p.getName());
json.put("distance",p.getDistance());
json.put("quantity",p.getQuantità());
}
}
result=json.toString();
String path = Environment.getExternalStorageDirectory()
.getAbsolutePath() + "/droidText/";
//FileWriter file=null;
/* try {
file = new FileWriter(path+"filename5.json");
file.write(result);
}catch(IOException ie){}
finally{
file.flush();
file.close();
}*/
FileWriter file = new FileWriter(path+"filename31.json");
file.write(result);
file.close();
System.out.println("Successfully wrote Json result to file.");
/*catch(IOException r){
}*/
System.out.println(result);
return result;
}
JsonObjectクラス:
private static class JsonObject {
public void put(String name, String name1) {
}
}
Jsonファイルに保存しようとしていますか? – PVR
チェックボックスの名前が –