Retrieve images of particular folder in Android

后端 未结 4 1399
一个人的身影
一个人的身影 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 04:04

    Once check this one

     File sdcardPath = new File(Environment.getExternalStorageDirectory()
        .getPath() + "/100ANDRO"); 
       Log.v(sdcardPath.getPath());
    

    Check if this prints the correct path which you require If sdcardPath is not null then try the following logic

    int imageCount = sdcardPath.listFiles().length;
      for (int count = 0; count < imageCount - 1; count++) {
       ImageView eachImageView= new ImageView(this);
       Bitmap bmp = BitmapFactory.decodeFile(sdcardPath.listFiles()[count].getAbsolutePath());
       eachImageView.setImageBitmap(bmp);
    

提交回复
热议问题