Refresh Android mediastore using adb

前端 未结 5 961
鱼传尺愫
鱼传尺愫 2020-12-04 08:42

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

5条回答
  •  醉话见心
    2020-12-04 09:05

    The MEDIA_MOUNTED intent is no longer permitted (post KitKat) for non-system apps; try this instead.

    It’s not recursive, though, and has to be run on the exact_file_name, so it’s not a good replacement.

    adb shell am broadcast \
        -a android.intent.action.MEDIA_SCANNER_SCAN_FILE \
        -d file:///mnt/sdcard/Music/
    

    If you need to rescan recursively, you can use this command (fix paths accordingly):

    adb shell "find /mnt/sdcard/Music/ -exec am broadcast \
        -a android.intent.action.MEDIA_SCANNER_SCAN_FILE \
        -d file://{} \\;"
    

    Or like this (if above won't work for you):

    adb shell "find /mnt/sdcard/Music/ | while read f; do \
        am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE \
        -d \"file://${f}\"; done"
    

提交回复
热议问题