There is a problem with accessing the file through Windows Explorer. My files are saved on non root device. I can only view them using Android's embedded file manager, but they have trouble viewing with Windows Explorer. I plug in and plug-out my device, but It does not work well. Here is my code:
Public class LoggerUtil {personal file sdRoot; Private string; The operation of the private file; Private file log; Private Reference ApplicationContence = MApp.getContext (); Public LoggerUtil () {} @SuppressLint ("SimpleDateFormat") public file createNewLogFile () {string currentDetate time = new SimpleDateform ("yyyyMMDHHmmss"). Format (new date ()); String path = sdRoot.toString () + DIR + "log" + current data and time + ".txt"; Return new file (path); } @SuppressLint ("SimpleDateFormat") Public Zero Approval (String Text) {sdRoot = Environment.getExternalStorageDirectory ()); Dir = "/ Android / data /" + applicationContext.getPackageName () + "/ log /"; Working Directory = New File (SDRoot, DIR); WorkingDirectory.mkdirs (); Log = createNewLogFile (); If (ABC.isOK ()) {file logFile = log; If (! LogFile.exists ()) {try {logFile.createNewFile ()}} hold (IOException e) {e.printStackTrace (); }} Try {String PresentDetate Time = New Simple Data Format ("yyyy-MM-dd HH: mm: ss"). Format (new date ()); // Breaded water is the right to set the endand for display / flag BufferedWriter buf = new BufferedWriter (new FileWriter (logfile, true)); Buf.append (current date and time + "text"); Buf.newLine (); Buf.close (); } Hold (IOException e) {e.printStackTrace (); }}}
}
My execution is:
LoggerTotal logler = new loggerUtil (); Loger.appendLog ("test");
No comments:
Post a Comment