Hi, I am trying to find the sqlite database used by the MediaStore. As far as I understand, the MediaStore contains amongst others the playlists defined in the default Music app. I actually would like to duplicate a playlist, but the app does not allow that. Somehow I thought I could fix this if I just could find the actual db file. But I got completely sidetracked now, because I just cannot find the db. Btw, I am running FroYo.
+2
A:
The proper way to do this is to use the content provider to query media store and do any kind of modifications to the tables from there.
Quick example of how you would query all artists in the MediaStore.
String[] proj = { MediaStore.Audio.Media._ID,
MediaStore.Audio.Media.DATA,
MediaStore.Audio.Media.DISPLAY_NAME,
MediaStore.Audio.Artists.ARTIST };
//managed query doesn't need startManagingCursor called on the cursor
Cursor c = managedQuery(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
proj, null, null, null);
smith324
2010-08-28 23:37:26
Right. That's the programmatic way. I guess in this case I could just get hold of the Music player code in the first place and add a duplicate playlist function. My point, however, was that I wanted to do a quick hack, by editing the sqlite database directly using any sqlite GUI. I just wonder which file contains the db?
Hardy
2010-08-29 15:55:34
Ah I see, you didn't mention you wanted to use a sqlite GUI to do this. Well as long as you have a rooted phone you should have no issues pulling the DB. I'm gonna look into its location and get back to you.
smith324
2010-08-30 15:21:12
Did you find the location of the db. I really cannot find it :(
Hardy
2010-09-13 14:25:42
A:
Having a look at the Android source the class we're interested in seems to be android.provider.MediaStore
and in there, the getDatabaseForUri()
method seems generate a different database for each external storage card and one called internal.db
.
So I think the file you're interested in is:
/data/data/com.android.providers.media/databases/internal.db
However, my copy of that database doesn't have the audio_playlists
table used in the Java source so I'm not certain this is right.
Dave Webb
2010-09-13 15:35:37
How do you access the data under /data. I am using ASTRO to browse the data on my phone, but /data is empty. I am not sure though whether this is because the directory is really empty or because of permission settings.
Hardy
2010-09-20 08:47:04
`/data` is owned by `root` so you're not going to be able to browse it with ASTRO on an unrooted phone. Try connecting your phone to your development PC and using `adb shell`. I think this runs with root permissions on all phones but I don't have an unrooted phone with me to check this.
Dave Webb
2010-09-20 10:29:27
Thanks for the info. That helps a lot and explains also why I had such a hard time finding this file. Unfortunately, 'adb shell' does not seem to run as root on an un-rooted phone :( How hard can it be!?
Hardy
2010-09-20 14:07:36
@Hardy - Just had a quick Google - if you use `adb shell` and then run the `su` command you should get root access. On an unrooted phone it seems only the `root` and `shell` users can use `su` but I guess `adb shell` runs as the `shell` users so it should work.
Dave Webb
2010-09-20 15:28:38
Hmm, I don't have permissions for that. Seems related to http://stackoverflow.com/questions/2078710/android-adb-access-to-application-databases-without-root
Hardy
2010-09-21 12:23:01