Reputation: 213
I need a little help in trying to figure out a problem that I am having. I have an application that will query all the images on the phone and display them in a GridView. I was able to do this and populate the list. The problem is when I am accessing the list and getting information from the items from a query. The cursor is telling me that the item has a file path of
/mnt/sdcard/images/media/file.jpg
but the path is only
/sdcard/images/media/file.jpg
This is the code I used to populate the list.
// Set up an array of the Thumbnail Image ID column we want
String[] projection = {MediaStore.Images.Thumbnails._ID};
// Create the cursor pointing to the SDCard
//returns the cursor that checks the sdcard for Thumbnail id's
cursor = managedQuery(
MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,
projection,
// Which columns to return
null,
// Return all rows
null,
MediaStore.Images.Thumbnails.IMAGE_ID);
// Get the column index of the Thumbnails Image ID
columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Thumbnails._ID);
The items DO ACTUALLY display but the path is wrong when I retrieve them from another cursor. ?????? I am a bit lost.
I have used it in emulator and on my physical device. Same problem. I get an ERROR stating that the path is NULL and the program crashed.
Is there a way that I can get the MediaStore to query the EXTERNAL_CONTENT_URI and give the correct path I need? Also, when I used it on my physical phone, the query when to the first directory on my sdcard with images then stopped, and way for it to query more directories?
Upvotes: 0
Views: 2694
Reputation: 3305
Did you try MediaStore.Images.Media.EXTERNAL_CONTENT_URI
?
Also managedQuery()
is deprecated, use getContentResolver().query()
.
Upvotes: 3