MediaScannerConnection#scanFile converts directories into files when accessing them with USB-MTP on Android 5 Lollipop

后端 未结 1 1683
时光说笑
时光说笑 2020-12-19 05:48

Changes like renaming a file triggered by an app only appear to the USB-MTP interface after reboot of the Android device or after you registered the new fil

相关标签:
1条回答
  • 2020-12-19 06:24

    I ended up creating a dummy text file in each directory I wanted to make visible, and use scanFile on the file.

    1) create directory, but don't "scan" directories

    2) copy file to directory

    3) run scanFile on the filePath

    MediaScannerConnection.scanFile (_application, new String[] { filePath }, null, null);
    
    0 讨论(0)
提交回复
热议问题