Dirindon
Dirindon

Reputation: 664

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

Upvotes: 3

Views: 16449

Answers (1)

Leonid Veremchuk
Leonid Veremchuk

Reputation: 1963

Just use Uri:

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

and:

new File(fileUri.getPath());

Upvotes: 5

Related Questions