i trying write json data file, below have tried.
jsonobject obj = new jsonobject(); try { obj.put("name", "mkyong.com"); } catch (jsonexception e2) { e2.printstacktrace(); } try { obj.put("age", new integer(100)); } catch (jsonexception e2) { e2.printstacktrace(); } arraylist list = new arraylist(); list.add("msg 1"); list.add("msg 2"); list.add("msg 3"); try { obj.put("messages", list); } catch (jsonexception e1) { e1.printstacktrace(); } fileoutputstream fs; string filename = "sample.json"; try { fs = openfileoutput(filename, context.mode_append); fs.write(obj.tostring().getbytes()); fs.close(); } catch (filenotfoundexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); }
i dont errors though, file created not visible. should have read verify written properly?? of great if can see created file in src folder since write many stuff, easy validate.
probably lame, can locate file in ddms perspective , pull out tag will visible!! there, can pull out , view local computer!!
Comments
Post a Comment