Created
September 3, 2014 07:22
-
-
Save laaptu/3020d64aa7a7d3452eab to your computer and use it in GitHub Desktop.
Get last clicked image path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private int getLastImageId() { | |
final String[] imageColumns = {MediaStore.Images.Media._ID, MediaStore.Images.Media.DATA}; | |
final String imageOrderBy = MediaStore.Images.Media._ID + " DESC"; | |
Cursor imageCursor = getActivity().getContentResolver().query(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(TAG, "getLastImageId::id " + id); | |
Log.d(TAG, "getLastImageId::path " + fullPath); | |
imageCursor.close(); | |
return id; | |
} else { | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment