Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refresh Android mediastore using adb

I'm using adb to sync music on an android phone. Essentially, I rm the existing music directory and push replacement music files.

I'd like to be able to use adb to force a rescan, so that the google music player (and other apps) works properly with the new songs and playlists.

According to How can I refresh MediaStore on Android? you can force a rescan by broadcasting an appropriate intent.

adb provides 'shell am broadcast', which would seem to allow me to force a rescan from adb.

Alternatively I could run a rescan app or reboot, but I'd like to trigger the rescan from adb

What adb command should I issue? The music files and playlists are all in /sdcard/music.

like image 387
foosion Avatar asked Jul 29 '13 15:07

foosion


People also ask

How do I refresh media store on Android?

Search for "Media Storage" but if it's not shown, you may need to unhide it by selecting "Show system" in the 3-dot option menu. Select "Media Storage" and then tap on the "Storage" option. Select "Clear Data" and "OK" when the confirmation dialog appears. This will reset the Android Media Scan database.

What does adb sync do?

adb-sync is a tool to synchronize files between a PC and an Android device using the ADB (Android Debug Bridge).

Can I run adb commands on Android?

Finally, you can run ADB commands on your Android device without any computer. You don't need to add adb or adb shell initializers in this app as you are already within the local ADB shell. Just run the operative part of the command and then tap the “Enter” button on the keyboard.


1 Answers

The rescan apps use a media mount intent to kick off the media scanner. You can use am broadcast to send the same intent.

The command is:

adb shell am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///sdcard 
like image 104
user2892047 Avatar answered Sep 21 '22 13:09

user2892047