where I find the file modified by an android application -
i want save data in output file using following code. don't know find file after execution of application.
try { // open myfilename.txt writing outputstreamwriter out = new outputstreamwriter(openfileoutput("myfile.txt", context.mode_private)); // write contents on mysettings file out.write("x="+float.tostring(xx)+" y="+float.tostring(yy)+" z="+float.tostring((zz))+" puissance="+float.tostring(magneticstrenght)); // close file out.close(); } catch (java.io.ioexception e) { //do if ioexception occurs. log.e("exception", "file write failed: " + e.tostring()); }
thank answers.
this file stored application data. can not view file file manager until phone rooted. better if provide external directory path like:
file openfilename= new file(environment.getexternalstoragedirectory(),"myfile.txt"); try { // open myfilename.txt writing fileoutputstream f = new fileoutputstream(file); // write contents on mysettings file printwriter pw = new printwriter(f); pw.println(("x="+float.tostring(xx) +" y="+float.tostring(yy) +" z="+float.tostring((zz))+" puissance=" +float.tostring(magneticstrenght)); // close file pw.flush(); pw.close(); f.close(); } catch (java.io.ioexception e) { //do if ioexception occurs. log.e("exception", "file write failed: " + e.tostring()); }
Comments
Post a Comment