简体   繁体   中英

How to get a File using MediaStore.Downloads for a file in the Downloads directory?

The documentation says MediaStore.Downloads can be used, but it does not have any example of reading a downloaded file. All the examples I could find on the internet were about downloading and saving files using MediaStore.Downloads , but all I want is reading an already downloaded file.

Let's say that I drag-and-dropped "sample.epub" file into the Android emulator. It is saved to the "Downloads" directory by the emulator. Now, how can I get a File of this "sample.epub" so that I can pass it to the constructor of the ZipFile class ?

 File file = new File(Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_DOWNLOADS), "sample_epub");

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