eclipse - File android , add to the file after creating -



eclipse - File android , add to the file after creating -

hello have code :

protected void createfile(string text) { fileoutputstream fos = null; seek { fos = openfileoutput("mynote2.txt", mode_private); fos.write(text.getbytes()); toast.maketext(getapplicationcontext(), "comment added succesfully", toast.length_short).show(); } grab (filenotfoundexception e) { log.e("createfile", e.getlocalizedmessage()); } grab (ioexception e) { log.e("createfile", e.getlocalizedmessage()); } { if (fos != null) { seek { // drain stream fos.flush(); fos.close(); } grab (ioexception e) { // todo auto-generated grab block e.printstacktrace(); } } }

i making comment scheme , want come in comments , when write comment press button comment created , new file created "mynote2.txt" when come in code 1 time again , doesn't save file , create 1 time 1 time again lastly comment edited , , want come in file not create new file

i guess in openfileoutput("mynote2.txt", mode_private) method you'll creating new fileoutputstream object. utilize fileoutputstream (file file, boolean append) constructor , give 2nd parameter true , it'll append info existing file.

android eclipse file

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -