Checking where the file is stored in android? -
i writing log data file in android. unable understand file stored on android device ( google nexsus 7 ). , how should contents of file ?
following piece of code using write log data file.
public file appendinglog(string logdata){ try { file logfile = new file(environment.getexternalstoragedirectory(), "yourlog.txt"); if (!logfile.exists()) { try { logfile.createnewfile(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } } try { bufferedwriter buf = new bufferedwriter(new filewriter(logfile, true)); buf.append(logdata); buf.newline(); buf.close(); } catch (ioexception e) { e.printstacktrace(); } } catch (exception e) { e.printstacktrace(); } return logfile; }
android.util.log.d("myapp", logfile.tostring());
Comments
Post a Comment