Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.ContentResolver;
import android.content.ContentUris;

import android.database.Cursor;

import android.net.Uri;
import android.provider.MediaStore;

public class Main {
    public static String getThumbnailPathFromURI(Uri contentUri, ContentResolver content_resolver) {

        String uri = "";

        Cursor cursor = MediaStore.Images.Thumbnails.queryMiniThumbnail(content_resolver,
                ContentUris.parseId(contentUri), MediaStore.Images.Thumbnails.MINI_KIND, null);

        if (cursor != null && cursor.getCount() > 0) {
            cursor.moveToFirst();//**EDIT**
            uri = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Thumbnails.DATA));
        }

        return uri;
    }
}