I have geo tagging enabled in my phone camera. It saves latitude and longitude information (I've checked). I'm trying to read it like this
import static android.provider.MediaStore.Images.ImageColumns.*;
Uri queryPhotoUri = ...; //uri of photo
String[] photoProjection = {LATITUDE,LONGITUDE,ORIENTATION,DESCRIPTION};
Cursor photoData = getContext().getContentResolver().query(
queryPhotoUri, photoProjection, null, null, null);
int latIdx = photoData.getColumnIndex(LATITUDE);
int lngIdx = photoData.getColumnIndex(LONGITUDE);
int oriIdx = photoData.getColumnIndex(ORIENTATION);
int txtIdx = photoData.getColumnIndex(DESCRIPTION);
boolean latExists = !photoData.isNull(latIdx);
boolean lngExists = !photoData.isNull(lngIdx);
boolean oriExists = !photoData.isNull(oriIdx);
boolean txtExists = !photoData.isNull(txtIdx);
oriExists evaluates to TRUE, the rest to FALSE. Why? Does the Image Content Provider write latitude and longitude as an exif attribute to the photo file, or does it store them somewhere else?
Also, I'm trying to write description of the photo to the DESCRIPTION column, but it's not saved. Where is the description stored?
Edit: This is getting stranger. I've checked the framework source and the MediaProvider class reads the exif tags from the photo and stores them in the database. However, the latitude and longitude fields are not stored for some reason.
I suggest you to use ExifInterface
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With