简体   繁体   中英

How to get path to res.drawable folder to copy a file?

I am writing my app in AndroidStudio , I got gif file in my drawable/gifs folder and I wish to copy that file to MediaStore.Images.Media folder after clicking a button.

Currently I can't get my gif path even when using some answers posted. The path I've tried using is android.resource://com.example.bartoszwolski.cluainkeyboard/drawable/gifs/my.gif

Just use Uri:

Uri fileUri = Uri.parse("android.resource://your_packagename/" + R.drawable.your_image_id);

and:

new File(fileUri.getPath());

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