私はthumnailを取得しようとしていますパス、ビットマップオブジェクトではありません。
これらのクエリを実行すると、何らかの理由でサムネイルパスの一部がnullになります。 (私は1028のサムネイル画像をデバイスに持っていますが、カーソルの長さは実際に1028ですが、まだヌルを返しています)私はチェックしたので1028サムネイル画像があることを知っています。 は、ここに私のコードです:サムネイルファイルのパスを取得する
String[] projection = {MediaStore.Images.Thumbnails._ID};
// Create the cursor pointing to the SDCard
cursor = this.getContentResolver().query(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
Log.d(Global.TAG, "BEFORE");
columnIndex = cursor.getColumnIndex(MediaStore.Images.Thumbnails._ID);
Log.d(Global.TAG, "AFTER1");
for(int i =0;i<cursor.getCount();i++){
cursor.moveToPosition(i);
Log.d("MyTag","BBABA" + i +" : " + getThumbnailPathForLocalFile(cursor.getLong(columnIndex)));
}
cursor.close();
マイgetThumbnailPathForLocalFile:
String getThumbnailPathForLocalFile(long fileId)
{
// Log.d(Global., msg)
Cursor thumbCursor = null;
try
{
thumbCursor = this.getContentResolver().
query(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI
, null
, MediaStore.Images.Thumbnails.IMAGE_ID + " = " + fileId+ " AND "
+ MediaStore.Images.Thumbnails.KIND + " = "
+ MediaStore.Images.Thumbnails.MINI_KIND , null, null);
if(thumbCursor.moveToFirst())
{
// the path is stored in the DATA column
int dataIndex = thumbCursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
String thumbnailPath = thumbCursor.getString(dataIndex);
return thumbnailPath;
}
}
finally
{
if(thumbCursor != null)
{
thumbCursor.close();
}
}
return null;
}
ここに私のlogcatです: http://pastebin.com/UZLZF9Pg
確認した後、私は私が送っIDはちょうどのための指標のようであることがわかりループ。 私のコードがうまく動作するとは思えないので、他のコードも素晴らしいでしょう。
なぜあなたはMediaStore.Images.Thumbnails.DATAをMediaStore.Images.Thumbnails._IDにあなたのPROJECTIONを設定していませんでしたか? –
@IgorGanapolskyわかりません。私はその模範をどこかで取ったと思う。それが問題を解決するかもしれないと思う?とにかく、それはまだ不安です。 – idish
解決策のように{MediaStore.Images.Thumbnails.DATA}を使用したので、私は尋ねていました。あなたが別のアプローチをしていれば、私は興味がありました。 –