So now that you've got a rooted phone (with some kind of super user app, I user SuperSU ) have you ever thought it would be fun to change things about apps which you can't other wise. Cheating at games comes to mind, but there's loads of other things you could do by playing with the databases which back Android Apps. This is also very useful if you are developing an app which uses a database and you want to have a look at whats in your database. The other thing you'll need before we start is the Android Debugging Bridge which you can get from the Android Developer web page as part of the SDK with some help on it here
So lets go.....
Step 1.
Open up a terminal and navigate to the install directory you installed the android SDK to.
On my machine it looks like this.
C:\Users\Rob\AppData\Local\Android\android-studio\sdk\platform-tools>
Step 2.
Run the following command to make sure you're device is listed
This will show you your device connected to the ADB. If you don't see any devices here you might want to check the Android Developer pages for some help
Step 3.
Run the following command.
Now your connected to the Lunix terminal of your device. So far so good but we need to give your selves super user permissions to do this.
Step 4.
Simply issue the following command and the accept the prompt (if the super user app your using issues one) on the device.
Step 5.
Now that you're a super user you can do pretty much anything, but remember, with great power comes...well you know.
Anyway now you'll want to change down a couple of levels as follows and list the directory contents.
Step 6.
What you'll see here is a lost of pretty much all the apps you've got installed, including the out of the box ones. This is pretty much your "Program Files" directory on Android. Now pick an app you'd like to mess with and change in to its directory and then on down into its database directory. I'm going to change into the directory of the popular Cycling app Strava. Note that not all apps have a database directory so if not there isn't much you can do. Well you can edit their properties files and other files you find there.
Step 7.
Now that you know where the database is located for your app change but up to the root directory and see if you have sqlite3 installed bu doing the following.
Step 8.
As you can see I've got sqlite3 installed. If you don't, have no fear just go and grab the installer here and install it and then try it again.
Once your ready to open your first database simply do the following.
Step 9.
Well there you have it. Get your SQL on and have fun. A couple of handy commands for sqlite3 are .exit to quit and .tables to show you all the tables in the database. Once you've got all them you can simply select or modify their data in anyway you like. Have fun.
Note: to exit simply type .exit to quite sqlite, then exit to quite super user, then exist to quit adb and finally exit to quit the command prompt.
Run the following command to make sure you're device is listed
C:\Users\Rob\AppData\Local\Android\android-studio\sdk\platform-tools>adb devices * daemon not running. starting it now on port 5037 * * daemon started successfully * List of devices attached 003f7cf0df1ab41d device
This will show you your device connected to the ADB. If you don't see any devices here you might want to check the Android Developer pages for some help
Step 3.
Run the following command.
C:\Users\Rob\AppData\Local\Android\android-studio\sdk\platform-tools>adb shell shell@mako:/ $
Now your connected to the Lunix terminal of your device. So far so good but we need to give your selves super user permissions to do this.
Step 4.
Simply issue the following command and the accept the prompt (if the super user app your using issues one) on the device.
shell@mako:/ $ su su root@mako:/ #
Step 5.
Now that you're a super user you can do pretty much anything, but remember, with great power comes...well you know.
Anyway now you'll want to change down a couple of levels as follows and list the directory contents.
root@mako:/ # cd data/data/ cd data/data/ root@mako:/data/data # ls ls at.mroland.android.apps.nfctaginfo com.adobe.air com.adobe.reader com.android.backupconfirm com.android.bluetooth com.android.browser.provider com.android.calculator2 com.android.cellbroadcastreceiver com.android.certinstaller com.android.chrome com.android.contacts com.android.defcontainer com.android.documentsui ...
Step 6.
What you'll see here is a lost of pretty much all the apps you've got installed, including the out of the box ones. This is pretty much your "Program Files" directory on Android. Now pick an app you'd like to mess with and change in to its directory and then on down into its database directory. I'm going to change into the directory of the popular Cycling app Strava. Note that not all apps have a database directory so if not there isn't much you can do. Well you can edit their properties files and other files you find there.
root@mako:/data/data # cd com.strava/databases/ cd com.strava/databases/ root@mako:/data/data/com.strava/databases # ls ls google_analytics.db google_analytics.db-journal mixpanel mixpanel-journal strava strava-journal root@mako:/data/data/com.strava/databases #
Step 7.
Now that you know where the database is located for your app change but up to the root directory and see if you have sqlite3 installed bu doing the following.
root@mako:/data/data/com.strava/databases # cd ../../../../ cd ../../../../ root@mako:/ # sqlite3 sqlite3 SQLite version 3.7.16 2013-03-18 11:39:23 [www.ptsoft.org] [www.ptdave.com] Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite>
Step 8.
As you can see I've got sqlite3 installed. If you don't, have no fear just go and grab the installer here and install it and then try it again.
Once your ready to open your first database simply do the following.
root@mako:/ # sqlite3 /data/data/com.strava/databases/strava sqlite3 /data/data/com.strava/databases/strava SQLite version 3.7.16 2013-03-18 11:39:23 [www.ptsoft.org] [www.ptdave.com] Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite>
Step 9.
Well there you have it. Get your SQL on and have fun. A couple of handy commands for sqlite3 are .exit to quit and .tables to show you all the tables in the database. Once you've got all them you can simply select or modify their data in anyway you like. Have fun.
Note: to exit simply type .exit to quite sqlite, then exit to quite super user, then exist to quit adb and finally exit to quit the command prompt.