How can I save a json object
in a file in sdcard?
Asked
Active
Viewed 4,805 times
-1

Amit Anand
- 1,225
- 1
- 16
- 40

user1632949
- 615
- 3
- 9
- 18
-
get a string representation via `jsonObject.toString()` and write it to the file like there http://stackoverflow.com/questions/3551821/android-write-to-sd-card-folder – nikis May 08 '14 at 14:44
1 Answers
6
Just get a String from the JSONObject and write it into the file like this:
String content = json.toString();
FileWriter fw = new FileWriter("path");
BufferedWriter bw = new BufferedWriter(fw);
bw.write(content);
bw.close();
You will of course need to catch/throw exceptions and so on.

schubakah
- 425
- 4
- 13