开发者

How to retrieve images stored in Gallery folder of Android device

开发者 https://www.devze.com 2023-01-30 12:42 出处:网络
Hi I am writing an Android application in which I want to retrieve the images stored in Gallery folder of Device/emulator. Can any one开发者_开发知识库 give me sample code regarding how to achieve th

Hi

I am writing an Android application in which I want to retrieve the images stored in Gallery folder of Device/emulator. Can any one开发者_开发知识库 give me sample code regarding how to achieve this.

Thanks and Regards


If you have path where your images are stored, use this code to get image as bitmap.

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());
 }



You need to iterate through the path: ex

File f=new File("path of dir");
Now get all files using: f.listFiles();

This is s fair idea..........
Hope it will help........


Just for picking them?. If so, you can use this intent:

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");

Ger

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号