On a certain tap event, I ask the user to add an image. So I provide two options:
I tried the following code snippet from the post I mentioned in my comment.. and it's working fine for me.
/**
* Gets the last image id from the media store
*
* @return
*/
private int getLastImageId() {
final String[] imageColumns = { MediaStore.Images.Media._ID,
MediaStore.Images.Media.DATA };
final String imageOrderBy = MediaStore.Images.Media._ID + " DESC";
Cursor imageCursor = managedQuery(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, imageColumns,
null, null, imageOrderBy);
if (imageCursor.moveToFirst()) {
int id = imageCursor.getInt(imageCursor
.getColumnIndex(MediaStore.Images.Media._ID));
String fullPath = imageCursor.getString(imageCursor
.getColumnIndex(MediaStore.Images.Media.DATA));
Log.d(getClass().getSimpleName(), "getLastImageId::id " + id);
Log.d(getClass().getSimpleName(), "getLastImageId::path "
+ fullPath);
imageCursor.close();
return id;
} else {
return 0;
}
}
OutPut in logcat:
09-24 16:36:24.500: getLastImageId::id 70
09-24 16:36:24.500: getLastImageId::path /mnt/sdcard/DCIM/Camera/2012-09-24 16.36.20.jpg
Also I don't see any harcoded names in the above code snippet. Hope this helps.