Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
External storage access denied in xamarin android
Devendra Kumar
Jan 19 2018 3:22 AM
242
Hello all
I just started building apps using xamarin.android and I got stuck in between.
I am working with images and uses the compress function of bitmap and when I read/write image on phone memory, it works fine but when I tried to write on ezxternal sd card, it shows access denied exception, although reading from it is working fine.I had also set the permission of ReadExternalStorage and WriteExternalStorage but still getting the exception.
Here is my code
// Path of PhotoUri and path that I retreived
//var PhotoUri = {content://com.android.providers.media.documents/document/image%3A9104}
//var path = /storage/D660-18BD/memorytest/20170930_230230.jpg
using
(var bmp = MediaStore.Images.Media.GetBitmap(ContentResolver, PhotoUri))
{
var fullPath = System.IO.Path.GetFullPath(path);
var dirName = System.IO.Path.GetDirectoryName(fullPath);
var filename = System.IO.Path.GetFileNameWithoutExtension(fullPath);
var ext = System.IO.Path.GetExtension(fullPath);
var newname = System.IO.Path.Combine(dirName, filename +
"IR"
+ ext);
var fs =
new
FileStream(newname, FileMode.OpenOrCreate);
// here I got the exception
bmp.Compress(Bitmap.CompressFormat.Jpeg, 90, fs);
fs.Close();
fs.Dispose();
}
Access to the path "/storage/D660-18BD/memorytest/20170930_230230IR.jpg" is denied.
Can anyone help me to get the solution.
Reply
Upload Source Code
Select only zip and rar file.
Post
Reset
Answers (
2
)
Android Wear App
About google map in android