View

Thursday, 17 May 2012

How to use Logcat Backup file in SD card

I used sample application to Backup the Logcat file in SD card.First it create the Sample_log_file.txt in the SD card Location and then we give  write to read the logcat file command like -d -f

The following code is
try {
          File filename = new File(Environment.getExternalStorageDirectory()+"/Sample_log_file.txt");
          filename.createNewFile();
          String cmd = "logcat -d -f "+filename.getAbsolutePath();
          Runtime.getRuntime().exec(cmd);
       } catch (IOException e) {
          e.printStackTrace();
        }
You must give the permission in AndroidManifest.xml
 <uses-permission android:name="android.permission.READ_LOGS"/>
 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Go and check the file in DDMS->open File Explorer->open Mnt(management)->SD Card->sample_log_file.txt
  



             /    **Log file shown in the word**/



1 comment:

  1. Awesome Blog. Thanks. Do keep posting such good blogs. Thanks for sharing Informative posts.
    ---------------------------------------------------------------------
    iPhone App Development And Android Application Development

    ReplyDelete