Android MediaStore sqlite db location
Asked Answered
A

4

7

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.

Aerify answered 28/8, 2010 at 21:16 Comment(0)
R
14

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.

Reta answered 13/9, 2010 at 15:35 Comment(5)
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.Aerify
/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.Reta
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!?Aerify
@Aerify - 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.Reta
Hmm, I don't have permissions for that. Seems related to #2079210Aerify
R
4

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);
Ruscher answered 28/8, 2010 at 23:37 Comment(4)
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?Aerify
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.Ruscher
Did you find the location of the db. I really cannot find it :(Aerify
Does the database contain FTS-Tables for full-text-search on playlist names and so on?Upswing
Y
3

the location is:

/data/data/com.android.providers.media/databases/internal.db

audio_playlists not in Tables, you can see it in Views. sql tool is:sqliteman,ubuntu13.10

Yawl answered 16/1, 2014 at 7:17 Comment(0)
A
0

For android 11 (Rooted stock version)

i found the database on this location

/data/data/com.android.providers.media.module/databases/internal.db (for system related files)

/data/data/com.android.providers.media.module/databases/external.db (for user related files).

** Please note add the world "module" to com.android.providers.media

Anatolio answered 2/11, 2023 at 19:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.