question

dmtrlbdv avatar image
dmtrlbdv asked

custom media files browser

I have application for android which can show media files from device MediaStore. Now I am trying to start it on Kindle fire and see crash with log that says I have not key "_id" after my loader finished. My code below must take mimeType and _id for future using it, but it crashes on kindle. Anybody know correct way to get Cursor for media ? I know i can use Intent, but i need multiple items selection and custom view for it. Thanks [b]final String[] projectionImage = { MediaStore.Images.Media._ID ,MediaStore.Images.Media.MIME_TYPE}; Cursor imagesCursor = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projectionImage, null, null, null); [/b] Additionally, my save image function not works for kindle fire. Help me, please to find good solution for working with media files on kindle fire (not using Intents)
fire tablet
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Sachin@Amazon avatar image
Sachin@Amazon answered
We are unable to reproduce the issue as the code provided by you works fine for us. Here is a sample method that will save all ImageUris on the Kindle Fire, using your code: private Vector getAllImageUris() { /* Create a vector to hold all image Uris. */ Vector imageUris = new Vector (); /* Execute the query, returning the "projectionImage" columns. */ final String[] projectionImage = { MediaStore.Images.Media._ID , MediaStore.Images.Media.MIME_TYPE }; Cursor imagesCursor = this.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projectionImage, null, null, null); /* Use Cursor to obtain the URI, put into the Vector. */ for(int i = 0; i < imagesCursor.getCount(); i++) { imagesCursor.moveToPosition(i); /* Get _ID value for the image. */ int columnIndex = imagesCursor.getColumnIndex("_ID"); String imageId = imagesCursor.getString(columnIndex); /* Construct the URI. */ Uri imageUri = Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, imageId); imageUris.add(imageUri); } imagesCursor.close(); return imageUris; } Hope this info helps.
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.