Forum Xamarin.Forms

How to copy image from Drawable folder to internal storage

I want a method that will allow me to copy an image from the Drawable folder to the internal storage, i searched the internet for solutions but i found some of them that did not work for me like this one :

Bitmap bm = BitmapFactory.decodeResource( getResources(), R.drawable.ic_launcher);
String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
File file = new File(extStorageDirectory, "ic_launcher.PNG");
outStream = new FileOutputStream(file);
bm.compress(Bitmap.CompressFormat.PNG, 100, outStream);
outStream.flush();
outStream.close();

help!

Posts

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    What does "didn't work" really mean? Threw exception? Couldn't find rescourse? Didn't have permission to write? Did you try to debug the code you've supplied? IE: Step through it line by line and confirm the run-time values are what you expected?

Sign In or Register to comment.