5

I am using HuaWeiNova device, and I tried to access it with aft-mtp-cli.

$ aft-mtp-cli
$ ls DCIM/

I got folders listed here:

|-photos
|-Camera
....

When I tried to list or download my photos in the Camera/ folder, I got nothing. Only the empty folders are listed and the folders that contains files are not shown at all. I am quite sure my photos are stored in the Camera folder in my cell phone. How come I could not access my photos with my computer ?

2
8

For accessing your Android device via USB in "File Transfer" mode your computer uses the MTP protocol. This protocol allows to list and read/write the files from/to your device.

What most people don't know is that the MTP protocol does not show the content of the file-system. Instead it uses the Android MediaStore Database (an SQLite database) which is populated by the Media Provider, a special daemon running on Android (app package name: com.android.providers.media).

If you create a new file/directory or delete something without notify this daemon the database and the file-system are out-of sync and you end up that you can see files already deleted or can't see existing files.

You can force the Android MediaStore to refresh it's database.

There are three way to do so, just pick one of the following:

  1. Reboot your phone

  2. Use one of the multitude of apps that can force a rescan of the sd-card

  3. Only for Android 4-7: Use the following ADB command-line (source):

    adb shell am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///sdcard

Resetting MediaStore Database

Some times it can happen that the MediaStore database is corrupted. In such a case open the app info page of com.android.providers.media (enable "show system apps") and clear storage of this app. Afterwards reboot the device.

After reboot login using your password/pin/pattern so that you can see the launcher. Then leave the device alone to regenerate the media database. This can take some minutes or hours depending on the number of media files you have on your phone.

If that still not resolves the problem of missing files and folders then may be you have a corrupted media file on your phone that prevents further scanning of the media files. In such a case you first have to identify the corrupt file and remove or repair it.

6
  • 1
    For Android 8 and above that adb command would not work. See my answer android.stackexchange.com/a/200785/96277.
    – Firelord
    Jan 24 '20 at 20:45
  • @Firelord Thanks for the info. If I draw the correct conclusion from your tests an Android 8 an updated app that sends this broadcast with an File object should work, right? And from my experience on Android 9 the MediaStore usually auto-updates the database so that there is no need for manually triggering an update.
    – Robert
    Jan 24 '20 at 20:57
  • Sorry, I can't interpret that conclusion for some reason, so can't comment on it. // I did come to know from you sometime ago that Android 9 automatically auto update the database so there is no need for a manual trigger. I had updated my answer there because mediaserver can be crased by an app (happened by an Xposed module) so an alternative solution was needed. In normal circumstances, yes, nobody would need to resort to command-line solution at all. So your answer is all good now. :)
    – Firelord
    Jan 25 '20 at 0:45
  • Well rebooting used to do that on Android 7.
    – NoBugs
    Jan 20 at 1:41
  • @Firelord how is this guy doing it so in this video youtube.com/watch?v=GitMOYdsA9I where he shows here i.imgur.com/9gou0yT.png windows explorer showing lots more folders than just DCIM and Pictures, ?!
    – barlop
    Jan 21 at 22:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.