import information into existing csv file android -



import information into existing csv file android -

my application create every day new csv file. want write new line information. should happen when press button. problem is, don't know how can open existing file , continues lastly info write. did seek lot, didn't find solution.

create file

file myfile = new file("/sdcard/protokolle" + date + "/protokoll.csv"); myfile.createnewfile(); fileoutputstream fout = new fileoutputstream(myfile); outputstreamwriter myoutwriter = new outputstreamwriter(fout); myoutwriter.append("date"); myoutwriter.append(','); myoutwriter.append(date); myoutwriter.append('\n'); myoutwriter.append('\n'); myoutwriter.close(); fout.close();

onclick

filewriter fwriter; seek { file sdcardfile = new file("/sdcard/protokolle" + date + "/protokoll.csv"); log.d("tag", sdcardfile.getpath()); fwriter = new filewriter(sdcardfile, true); fwriter.write("\n"); fwriter.write("test"); fwriter.write("test"); fwriter.write("\n"); fwriter.write("test"); fwriter.flush(); fwriter.close(); } grab (ioexception e) { e.printstacktrace(); }

change code

filewriter author = new filewriter(protokoll,true);

this allows append existing file. see java api doc filewriter. if file not exist, file created otherwise content appended.

android csv

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -