where to save a custom log file in android? -
i created class write log file , works well:
public class logfile { string route; context context; public logfile(context context, string date) { this.context = context; this.route= context.getfilesdir() + "/log_"+date+".txt"; } public void appendlog(string text){ file logfile = new file(ruta); if (!logfile.exists()){ try{ logfile.createnewfile(); } catch (ioexception e){ e.printstacktrace(); } } try{ bufferedwriter buf = new bufferedwriter(new filewriter(logfile, true)); buf.append(text); buf.newline(); buf.close(); } catch (ioexception e){ e.printstacktrace(); } }
}
but route generates /data/data/com.myaplication.myaplication/files/log_20130717.txt , cant access directory device. need access file if problem occurs device. file explorer of tablet see directories: /root/data , /root/android/data. android helps create aplication directory inside of these directories?. otherwise, tried put file in "sdcard/log_20130717.txt" permission denied.
what suggest me do?.
place in externalfilesdir()
, , don't forget android.permission.write_external_storage
.
Comments
Post a Comment