2013-03-20 89 views
1

我在网格视图中显示所有SD卡图像。事情是我必须显示设备的外部存储器上的所有图像,并在相同时间不显示摄像头图像。我知道,为此我需要得到相机桶ID或桶显示名称。我没有得到如何做到这一点。谁能帮助我如何做到这一点..显示所有的图像,除了特定的桶显示名称android

回答

1

试试这个。你可能需要修改这个

public static ArrayList<String> getPathOfAllImages(Activity activity) { 
     ArrayList<String> absolutePathOfImageList = new ArrayList<String>(); 
     String absolutePathOfImage = null; 
     String nameOfFile = null; 
     String absolutePathOfFileWithoutFileName = null; 
     Uri uri; 
     Cursor cursor; 
     int column_index; 
     int column_displayname; 
     int lastIndex; 



      uri = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI; 

      String[] projection = { MediaColumns.DATA, 
        MediaColumns.DISPLAY_NAME }; 

      cursor = activity.managedQuery(uri, projection, null, null, null); 
      column_index = cursor.getColumnIndexOrThrow(MediaColumns.DATA); 

      column_displayname = cursor 
        .getColumnIndexOrThrow(MediaColumns.DISPLAY_NAME); 


      while (cursor.moveToNext()) { 

       absolutePathOfImage = cursor.getString(column_index); 
       nameOfFile = cursor.getString(column_displayname); 

       lastIndex = absolutePathOfImage.lastIndexOf(nameOfFile); 

       lastIndex = lastIndex >= 0 ? lastIndex 
         : nameOfFile.length() - 1; 

       absolutePathOfFileWithoutFileName = absolutePathOfImage 
         .substring(0, lastIndex); 


        if (absolutePathOfImage != null&& !absolutePathOfImage.equals("/sdcard/DCMI/")) { 
         absolutePathOfImageList.add(absolutePathOfImage); 
        } 

      } 

使用absolutePathOfImageList来填充网格视图

1

Usualy相机图像存储在一个特定的文件夹,DCMI文件夹。只是不显示在DCMI文件夹中的图像,当你搜索SD卡中的图像时跳过该文件夹

+0

可以请你告诉我该怎么做 – indraja 2013-03-20 12:33:29