I'm using Xamarin for Android. I load an image and put it in ImageView, then I edit the image. Next I want to save that image to SD card.
Anyone know how to save the image into SD card because I only can find it in Java Android. I already try to convert the code from Java to C# but still get an error.
Any help, thanks in advance.
I get an error at InputStream iS = Resources.OpenRawResource(Resource.Drawable.Icon);
as the error is "cannot implicitly convert type 'System.IO.Stream' to 'Java.IO.InputStream'"
Here's the code:
Java.IO.File path = Android.OS.Environment.GetExternalStoragePublicDirectory (Android.OS.Environment.DirectoryPictures);
Java.IO.File file = new Java.IO.File (path, "Icon.png");
try {
path.Mkdirs();
InputStream iS = Resources.OpenRawResource(Resource.Drawable.Icon);
OutputStream oS = new FileOutputStream(file);
byte[] data = new byte[iS.Available()];
iS.Read(data);
oS.Write(data);
iS.Close();
oS.Close();
} catch (Exception ex) {
// ...
}