gpt4 book ai didi

android - 如何从 Sdcard 文件夹的子文件夹中获取图像?

转载 作者:行者123 更新时间:2023-11-29 14:33:46 26 4
gpt4 key购买 nike

以下代码用于从特定文件夹获取图像,但如何获取 sdcard 文件夹的子文件夹图像。

Cursor actualimagecursor = managedQuery(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, proj,
MediaStore.Images.Media.DATA + " like ? ",
new String[] { "%unzipped%" }, null);

抱歉英语沟通不好。

最佳答案

试试下面的代码

public void searchImageFromSpecificDirectory() {

String path = null;

String uri = MediaStore.Images.Media.DATA;
// if GetImageFromThisDirectory is the name of the directory from which image will be retrieved
String condition = uri + " like '%/GetImageFromThisDirectory/%'";
String[] projection = { uri, MediaStore.Images.Media.DATE_ADDED,
MediaStore.Images.Media.SIZE };
Vector additionalFiles = null;
try {
if (additionalFiles == null) {
additionalFiles = new Vector<String>();
}



Cursor cursor = managedQuery(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection,
condition, null, null);
if (cursor != null) {

boolean isDataPresent = cursor.moveToFirst();

if (isDataPresent) {

do {

path = cursor.getString(cursor.getColumnIndex(uri));
System.out.println("...path..."+path);
additionalFiles.add(path);
}while(cursor.moveToNext());
}
if (cursor != null) {
cursor.close();
}
}

} catch (Exception e) {
e.printStackTrace();
}
}

关于android - 如何从 Sdcard 文件夹的子文件夹中获取图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8655529/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com