1
我需要獲取相機(圖庫)拍攝的所有圖像的uri /路徑。我如何修改下面的代碼,只給圖片庫中的圖片。下面的代碼也給我從其他文件夾的圖像。僅從圖庫中獲取圖像
public ArrayList<String> getImages()
{
ArrayList<String> paths = new ArrayList<String>();
final String[] columns = { MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID };
final String orderBy = MediaStore.Images.Media.DATE_ADDED;
//Stores all the images from the gallery in Cursor
Cursor cursor = getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null,
null, orderBy);
//Total number of images
int count = cursor.getCount();
//Create an array to store path to all the images
String[] arrPath = new String[count];
for (int i = 0; i < count; i++) {
cursor.moveToPosition(i);
int dataColumnIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
//Store the path of the image
arrPath[i]= cursor.getString(dataColumnIndex);
paths.add(arrPath[i]);
}
return paths;
}
你可能會在這裏找到解決辦法... [鏈接](http://stackoverflow.com/questions/32652762/how-to-get -image-uri-from-gallery) –