我需要一點幫助,試圖找出我遇到的問題。我有一個應用程序將查詢手機上的所有圖像,並將其顯示在GridView中。我能夠做到這一點,並填寫名單。問題是當我訪問列表並從查詢中獲取項目信息時。光標告訴我該項目已如何使用MediaStore在GridView中顯示所有圖像
/mnt/sdcard/images/media/file.jpg
的文件路徑,但該路徑是唯一
/SD卡/圖像/媒體/文件.jpg
這是我用來填充列表的代碼。
// 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);
這些項目實際顯示,但是當我從另一個光標檢索它們時,路徑是錯誤的。 ?????? 我有點失落。
我已經在仿真器和我的物理設備上使用過它。同樣的問題。 我得到一個錯誤,指出路徑爲NULL並且程序崩潰。
有沒有一種方法可以讓MediaStore查詢EXTERNAL_CONTENT_URI並提供我需要的正確路徑? 此外,當我在我的物理電話上使用它時,查詢何時到我的SD卡上的第一個目錄與圖像然後停止,並且它的方式來查詢更多的目錄?