更改光标中的uri以从本地目录加载图像

时间:2011-10-21 10:23:48

标签: android

我下载了库加载图片的示例,如

Cursor imagecursor = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, 
                                  columns, null, null, orderBy);

当我打印MediaStore.Images.Media.EXTERNAL_CONTENT_URI时,我得到:

content://media/external/images/media .

但是如何从目录中更改为加载:

Environment.getExternalStorageDirectory() + "/test/";

我试过

Uri uri=Uri.parse(Environment.getExternalStorageDirectory() + "/test/");

Uri uri=Uri.parse("content:"Environment.getExternalStorageDirectory() + "/test/");

但它不起作用。有人能帮助我吗?

1 个答案:

答案 0 :(得分:0)

试试这个,

File ff = new File("/sdcard/test");

Cursor imagecursor = managedQuery(Uri.fromFile(ff), columns, null, null, orderBy);