Wednesday, 15 September 2010

android - append text to the end of the file -



android - append text to the end of the file -

i using below code segment write text end o file each time called. but, erasing old info , writes new info origin of file. how can prepare below code append new info always end of file ?

public boolean writetofile(string directory, string filename, string info ){ file out; outputstreamwriter outstreamwriter = null; fileoutputstream outstream = null; out = new file(new file(directory), filename); if ( out.exists() == false ){ out.createnewfile(); } outstream = new fileoutputstream(out) ; outstreamwriter = new outputstreamwriter(outstream); outstreamwriter.append(data); outstreamwriter.flush(); }

try set append boolean value true in fileoutputstream:

outstream = new fileoutputstream(out, true); outstreamwriter = new outputstreamwriter(outstream);

android

No comments:

Post a Comment