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.
我正在AndroidStudio中编写我的应用程序,我在drawable / gifs文件夹中获得了gif文件,并希望在单击按钮后将该文件复制到MediaStore.Images.Media文件夹。
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
目前,即使使用发布的答案,我也无法获得我的GIF路径。我尝试使用的路径是android.resource://com.example.bartoszwolski.cluainkeyboard/drawable/gifs/my.gif
1 个解决方案
#1
Just use Uri:
只需使用Uri:
Uri fileUri = Uri.parse("android.resource://your_packagename/" + R.drawable.your_image_id);
and:
new File(fileUri.getPath());
#1
Just use Uri:
只需使用Uri:
Uri fileUri = Uri.parse("android.resource://your_packagename/" + R.drawable.your_image_id);
and:
new File(fileUri.getPath());