Retrieve images of particular folder in Android

后端 未结 4 1398
一个人的身影
一个人的身影 2020-12-17 03:40

In my application I created the GridView to show the image from particular folder. The issue is that I want to retrieve images from the DCIM/100ANDRO folder. Wh

4条回答
  •  攒了一身酷
    2020-12-17 03:54

    First, assert the path that you are accessing and then use Bitmap.DecodePath(path) to load the bitmap. Try this out.

    File path = new File(Environment.getExternalStorageDirectory(),"DCIM/100ANDRO");
    if(path.exists())
    {
        String[] fileNames = path.list();
    }
    for(int i = 0; i < filename.length; i++)
    {
         Bitmap mBitmap = Bitmap.decodeFile(path.getPath()+"/"+ fileNames[i]);
         ///Now set this bitmap on imageview
    } 
    

提交回复
热议问题