Saturday 30 November 2013

Android SQLite browser without rooting the device

Its been many days I was finding difficult to check the data from DB present in phone internal memory. One solution was to pull 'mydatabase.sqlite' through the ADB but which requires a rooted device, one was to through Log.d(" ", " "); which is time consuming.

I have found one solution, just copy  'mydatabase.sqlite' database from your app (internal) to external memory.

Copy the same on your desktop and browse it with help Windows SQLite database browser

Copy the below code in your activity and pass the Source & Destination.

public void copy(File src, File dst) throws IOException {
    InputStream in = new FileInputStream(src);
    OutputStream out = new FileOutputStream(dst);

    // Transfer bytes from in to out
    byte[] buf = new byte[1024];
    int len;
    while ((len = in.read(buf)) > 0) {
        out.write(buf, 0, len);
    }
    in.close();
    out.close();
}

Don't forget to give write external memory permission

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 

Please share if you know any other method.

Also see 

  1. Also check out how to operate your Android phone from Window OS. 
  2. Android apk generation through command line 
  3. ADB over Wifi 
  4. EditText to TextView conversion 
  5. SVN for Android Eclipse