java - Appending to a file in android -


the question how append existing file. i'm using mode_append fileoutputstream fos = openfileoutput("filename", mode_append);. file created , object saved ,but when call method again on same file - nothing happens. mode_private works 1 insert creates new file every time it's called. spent whole day researching , couldn't find answer desperate help. public void createfile (view v) throws ioexception, jsonexception {

    jsonarray resultslog = new jsonarray();     jsonobject exercise2;      string pickval1 = stringarray[numpick1.getvalue()];     string pickval2 = stringarray[numpick2.getvalue()];     string pickval3 = stringarray[numpick3.getvalue()];     string pickval4 = stringarray[numpick4.getvalue()];       exercise2 =new jsonobject();     exercise2.put("rep", pickval1 + " kg  " + pickval2 + " kg  " + pickval3 + " kg  " + pickval4 + " kg  ");     exercise2.put("type", caller + "  on  " + date);     resultslog.put(exercise2);       string text= resultslog.tostring();       fileoutputstream fos = openfileoutput("resultsdat3", mode_append);       fos.write(text.getbytes());     fos.close();      //displaytext(this,r.id.stext,resultslog.tostring());     // finish(); } 

use filterwriter object. provides constructor option append writes current file, , takes care of creating file if needed.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -