Android 从手机';s内部存储器+;外部SD卡存储器?
我很困惑,我在下面发布的代码是否能从手机的内部存储器+外部SD卡存储器中检索所有图像Android 从手机';s内部存储器+;外部SD卡存储器?,android,file,list,Android,File,List,我很困惑,我在下面发布的代码是否能从手机的内部存储器+外部SD卡存储器中检索所有图像 final String[] columns = { MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID }; final String orderBy = MediaStore.Images.Media._ID; //Stores all the images from the gallery in Cursor Cursor cur
final String[] columns = { MediaStore.Images.Media.DATA,
MediaStore.Images.Media._ID };
final String orderBy = MediaStore.Images.Media._ID;
//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);
Log.i("PATH", arrPath[i]);
}
如果没有,那么如何从手机的内部存储器+外部SD卡存储器中获取所有图像
final String[] columns = { MediaStore.Images.Media.DATA,
MediaStore.Images.Media._ID };
final String orderBy = MediaStore.Images.Media._ID;
//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);
Log.i("PATH", arrPath[i]);
}
final String[]columns={MediaStore.Images.Media.DATA,
MediaStore.Images.Media.\u ID};
最终字符串orderBy=MediaStore.Images.Media.\u ID;
//将库中的所有图像存储在光标中
Cursor Cursor=getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,列,null,
null,orderBy);
//图像总数
int count=cursor.getCount();
//创建一个数组来存储所有图像的路径
字符串[]arrPath=新字符串[计数];
for(int i=0;i
试试这个--
public ArrayList getfilepath()
{
uriu=MediaStore.Images.Media.EXTERNAL\u CONTENT\u Uri;
String[]projection={MediaStore.Images.ImageColumns.DATA};
光标c=null;
SortedSet dirList=新树集();
ArrayList resultIAV=新的ArrayList();
字符串[]目录=null;
如果(u!=null)
{
c=managedQuery(u,投影,null,null,null);
}
if((c!=null)&(c.moveToFirst())
{
做
{
String tempDir=c.getString(0);
tempDir=tempDir.substring(0,tempDir.lastIndexOf(“/”);
试一试{
dirList.add(tempDir);
}
捕获(例外e)
{
}
}
而(c.moveToNext());
目录=新字符串[dirList.size()];
dirList.toArray(目录);
}
对于(int i=0;i