A.Pissicat
A.Pissicat

Reputation: 3295

Unable to find saved image

I'm very new to Android. I'm working with Xamarin and I have to take a picture with camera and save the picture.

I achieved to take the picture, I have a Bitmap object. Then I save it without error but when I try to find it, there is no file.

There is my code :

Bitmap imgBmp = /* image initialized */

//Save image on folder
var folderPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);               
var filePath = System.IO.Path.Combine(folderPath, "image1.png");
var stream = new System.IO.FileStream(filePath, FileMode.Create);
bool isOK = imgBmp.Compress(Bitmap.CompressFormat.Jpeg, 95, stream);
stream.Flush();
stream.Close();

I have no error when execute, isOK is true but when I search for the image.png I'm unable to find the file.

With debugger I saw that the path is : /data/user/0/com.myCompagny.MyAppli/files/image1.png but I can not see that folder.

Can someone help me to find my image1.png ?

Or to change the default folder to something like Pictures\MyApplication\image.png but I don't know how to find default folder for images.

Upvotes: 1

Views: 276

Answers (1)

kor
kor

Reputation: 141

Your file is there, but you have no permissions to see it. App directories are only readable to the owning app's uid. If you try to find your file through the shell, your uid is different.

You should try to use another folder path if you want to save file in a world readable location.

I'm just guessing but maybe System.Environment.SpecialFolder.CommonPictures would do.

Upvotes: 1

Related Questions