-1

我正在從圖庫中顯示圖像以下是代碼。 這裏我想打開一個特定文件夾中的圖像,該文件夾的名稱將在編輯文本中給出。 請幫助我這樣做,因爲它目前打開所有與應用程序無關並且很難識別圖像的圖像。在edittext中指定的打開的文件夾android

protected void LoadGalleryImages() { 
     final String[] columns = { MediaStore.Images.Media.DATA, 
       MediaStore.Images.Media._ID }; 
     final String orderBy = MediaStore.Images.Media._ID; 
     imagecursor = managedQuery(
       MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null, 
       null, orderBy); 
     int image_column_index = 0; 

     if (imagecursor != null) { 
      image_column_index = imagecursor 
        .getColumnIndex(MediaStore.Images.Media._ID); 
      count = imagecursor.getCount(); 
     } 

     imgSelected = new String[count]; 

     arrPath = new String[count]; 
     thumbnailsselection = new boolean[count]; 
     for (int i = 0; i < count; i++) { 
      if (imagecursor != null) { 
       imagecursor.moveToPosition(i); 
       // int id = imagecursor.getInt(image_column_index); 
       int dataColumnIndex = imagecursor 
         .getColumnIndex(MediaStore.Images.Media.DATA); 

       arrPath[i] = imagecursor.getString(dataColumnIndex); 
      } 

     } 
    } 

回答

0

普加,

這裏是打開你指定的文件夾來瀏覽文件的代碼:

Intent intent = new Intent(Intent.ACTION_GET_CONTENT); 
Uri uri = Uri.parse("folder path"); 

//Change content type as you want if you dont know then just mention "*/*" 
intent.setDataAndType(uri, "text/csv"); 

startActivity(Intent.createChooser(intent, "Open folder")); 

希望這會幫助你。

+0

我在哪裏寫這段代碼 – Pooja

+0

你是說在哪裏寫這段代碼?如果是,那麼用我的代碼替換「LoadGalleryImages()」的定義。它應該工作。 –

+0

我在下面的鏈接得到了解決方案http://stackoverflow.com/questions/14200309/android-display-images-from-specific-folder-in-gallery-view?rq=1 – Pooja

相關問題