如何检索Android设备Gallery文件夹中存储的图像
你好如何检索Android设备Gallery文件夹中存储的图像,android,Android,你好 我正在编写一个Android应用程序,我想在其中检索存储在Device/emulator的Gallery文件夹中的图像。任何人都可以给我关于如何实现这一点的示例代码。 感谢并问候您挑选它们?。如果是这样,您可以使用以下意图: Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); Ger如果您有存储图像的路径,请使用此代码以位图形式获取图像。 FileInputStream in
我正在编写一个Android应用程序,我想在其中检索存储在Device/emulator的Gallery文件夹中的图像。任何人都可以给我关于如何实现这一点的示例代码。
感谢并问候您挑选它们?。如果是这样,您可以使用以下意图:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
Ger如果您有存储图像的路径,请使用此代码以位图形式获取图像。
FileInputStream in;
BufferedInputStream buf;
try {
in = new FileInputStream("/sdcard/test2.png");
buf = new BufferedInputStream(in);
Bitmap bMap = BitmapFactory.decodeStream(buf);
image.setImageBitmap(bMap);
if (in != null) {
in.close();
}
if (buf != null) {
buf.close();
}
} catch (Exception e) {
Log.e("Error reading file", e.toString());
}
您需要遍历路径:ex 文件f=新文件(“目录路径”);
现在使用:f.listFiles()获取所有文件
这是一个公平的想法………
希望对……有帮助