Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to obtain thumbnail path from image path in android?
    primarykey
    data
    text
    <p>Basically i have image path that looks like this: /mnt/sdcard/Pictures/image.jpg And i need to get a path to thumbnail from it, in a fastest possible way.</p> <p>I am trying to use MediaStore.Images.Thumbnails.queryMiniThumbnail, but no matter what i pass i get null cursor. Thanks!</p> <p><strong>EDIT:</strong> This is the function that brings ALL of the image paths and thumbnail paths and stores them in a String. What I need is a function that returns thumbnail path for a specific image path (/mnt/sdcard/Pictures/image.jpg). Thanks</p> <pre><code>public String getThumbPaths(ThumbContext ctx) { Uri uri = MediaStore.Images.Thumbnails.getContentUri("external"); Cursor cursor = MediaStore.Images.Thumbnails.queryMiniThumbnails(ctx .getActivity().getContentResolver(), uri, MediaStore.Images.Thumbnails.MINI_KIND, null); int columnIndex = cursor.getColumnIndex(Thumbnails.IMAGE_ID); String[] filePathColumn = { MediaStore.Images.Media.DATA }; StringBuilder stringBuilder = new StringBuilder(); String id = MediaStore.Images.Media._ID + "=?"; String orientation="1"; for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { String imageId = cursor.getString(columnIndex); Cursor images = ctx.getActivity().managedQuery( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, filePathColumn, id, new String[] { imageId }, null); String filePath = ""; if (images != null &amp;&amp; images.moveToFirst()) { filePath = images.getString(images .getColumnIndex(filePathColumn[0])); } ExifInterface exifReader; try { exifReader = new ExifInterface(filePath); orientation=exifReader.getAttribute(ExifInterface.TAG_ORIENTATION); } catch (IOException e) { // TODO Auto-generated catch block //e.printStackTrace(); } stringBuilder.append(cursor.getString(1) + ";"); stringBuilder.append(filePath + ";"); stringBuilder.append(orientation + ";"); orientation="1"; } //cursor.close(); return stringBuilder.toString(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload