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

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -