I’m attempting to list off all exif attributes associated with an image in the gallery. Every getAttribute() returns null. When I debug and inspect the ExifInterface it has a valid file, and when I expand the “mAttributes” node the “Table” contains all of the EXIF data I’m looking for, but the “values,” “keySet” and “valuescollection” are null. Any idea where I’m going wrong?
Edit: Perhaps the problem is with how I’m obtaining the file name? I’ve updated the code below to give a more complete picture.
//create an array of thumbnail IDs
String[] ids = {MediaStore.Images.Thumbnails._ID};
//this pulls the file locations
cursor = managedQuery(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, ids, null, null, MediaStore.Images.Thumbnails.IMAGE_ID);
colIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Thumbnails._ID);
//at this point we need to target the gridview.
GridView gallery = (GridView) findViewById(R.id.gridView1);
//borrowed an adapter provided in the tutorial at http://mihaifonoage.blogspot.com/2009/09/displaying-images-from-sd-card-in.html
gallery.setAdapter(new ImageAdapter(this));
//now we attach a listener to our gridview.
gallery.setOnItemClickListener(new OnItemClickListener(){
public void onItemClick(AdapterView parent, View v, int position, long id)
{
String[] ids = {MediaStore.Images.Media.DATA};
cursor = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, ids, null, null, null);
colIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToPosition(position);
String image = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA));
ExifInterface clicked = null;
try {
clicked = new ExifInterface(image);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(clicked==null)
{
Toast.makeText(getApplicationContext() , "We were not able to load the file." , Toast.LENGTH_LONG).show();
}
else
{
TextView tv = (TextView) findViewById(R.id.messageCenter);
String message;
message = "Latitude: " + clicked.getAttribute(ExifInterface.TAG_GPS_LATITUDE) + "\n";
message += "Longitude: " + clicked.getAttribute(ExifInterface.TAG_GPS_LONGITUDE) + "\n";
message += "Make: " + clicked.getAttribute(ExifInterface.TAG_MAKE) + "\n";
message += "Model: " + clicked.getAttribute(ExifInterface.TAG_MODEL) + "\n";
message += "Date/Time: " + clicked.getAttribute(ExifInterface.TAG_DATETIME) + "\n";
message += "Flash: " + clicked.getAttribute(ExifInterface.TAG_FLASH) + "\n";
message += "Flocal Length: " + clicked.getAttribute(ExifInterface.TAG_FOCAL_LENGTH) + "\n";
message += "White Balance: " + clicked.getAttribute(ExifInterface.TAG_WHITE_BALANCE);
tv.setText(message);
}
}
});
Here’s what clicked looks like at runtime

Edit: I found that calling the values listed in the table works. However, if I expand mAttributes.table.[0].value.value the other information I’m looking for is listed in a char array. Why isn’t that information getting passed along?
Some pictures work fine – so the problem was the data, not the class or my code. I suspect some devices/applications encode their exif data in a non-standard way that ExifInterface cannot parse.