简体   繁体   中英

how to make nomedia file in Android Q

Android Q could not create file on public directory.

is there has any way to make nomedia file on public directory?

without below code

android:requestLegacyExternalStorage="true"

or is there has any way to hide media file on gallery

thank you.

i solved it using download manager easily.

just download empty file from web.

this is my sample code

val downloadManager = context.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
val request = DownloadManager.Request(Uri.parse("https://www.example.com/.nomedia"))
        .setTitle(".nomedia")
        .setDestinationInExternalPublicDir(Environment.DIRECTORY_DCIM, "/test/.nomedia") 
        .setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI or DownloadManager.Request.NETWORK_MOBILE)
        .setAllowedOverMetered(true) 
        .setAllowedOverRoaming(false)
downloadManager.enqueue(request)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM