I want to add GPS information to an image. I created that image at a Uri returned by ContentResolver.Insert(). I found out that ExifInterface can be used to write the GPS information, but to use it I need the path to the image.
My question is - How do I get the pathToSavedImage (in the below code)?
Note: This is Xamarin C# code, but Android answers are very relevant.
var cr = Application.Context.ContentResolver;
Android.Net.Uri uri = cr.Insert(MediaStore.Images.Media.ExternalContentUri, values);
Stream outputStream = cr.OpenOutputStream(uri, "w");
image.CopyTo(outputStream);
outputStream.Close();
ExifInterface exifInterface = new ExifInterface(pathToSavedImage);
exifInterface.SetAttribute(key, value);
exifInterface.SaveAttributes();
EDIT:
What's present in values?
var values = new ContentValues();
values.Put(MediaStore.Images.Media.InterfaceConsts.Title, title);
values.Put(MediaStore.Images.Media.InterfaceConsts.DisplayName, name);
values.Put(MediaStore.Images.Media.InterfaceConsts.MimeType, "image/jpeg");
values.Put(MediaStore.Images.Media.InterfaceConsts.Description, description);
values.Put(MediaStore.Images.Media.InterfaceConsts.DateTaken, Java.Lang.JavaSystem.CurrentTimeMillis());
var album = Environment.DirectoryPictures + Java.IO.File.Separator + albumName;
values.Put(MediaStore.Images.Media.InterfaceConsts.RelativePath, album);
values.Put(MediaStore.Images.Media.InterfaceConsts.IsPending, true);