How to append data one by one in existing file in android? -
how append data 1 one in existing file? using following code.. append data row order in file..how solve this?
private string savetext() { file sdcard = environment.getexternalstoragedirectory(); file dir = new file (sdcard.getabsolutepath()+file.separator+"gps"); dir.mkdirs(); string fname = "gps.txt"; file file = new file (dir, fname); fileoutputstream fos; try { fos = new fileoutputstream(file,true); outputstreamwriter out=new outputstreamwriter(fos); out.write(value1); out.close(); fos.close(); toast.maketext(getapplicationcontext(), "saved lat,long", toast.length_short).show(); } catch (exception e) { e.printstacktrace(); } return dir.getabsolutepath(); }
try code
try{ outputstreamwriter writer = new outputstreamwriter(new fileoutputstream(file,true), "utf-8"); bufferedwriter fbw = new bufferedwriter(writer); fbw.write(value1); fbw.newline(); fbw.close(); toast.maketext(getapplicationcontext(), "saved lat,long", toast.length_short).show(); } catch (exception e) { e.printstacktrace(); }
Comments
Post a Comment