title: Pick any file using intent in android
body: <p>I'm using following method to call pick any file but it doesn't work properly.</p>
  
  <pre><code>private void fileIntent(int file)
      {
          if ((ActivityCompat.checkSelfPermission(ICShowFileCabinetDetails.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) &amp;&amp; Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.M) {
              requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, file);
          } else {
              Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
              intent.setType("*/*");
              startActivityForResult(Intent.createChooser(intent, "Select File"), file);
          }
  
      }
  </code></pre>
  
  <p>Following permissions are set in manifest</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
      &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
  </code></pre>
  
  <p>OnActivtyresult</p>
  
  <pre><code>@Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (requestCode == SELECT_FILE &amp;&amp; data != null) {
              try {
                  mProPic = MediaStore.Images.Media.getBitmap(getApplicationContext().getContentResolver(), data.getData());
  
                  Uri selectedImage = data.getData();
  
                  String[] filePathColumn = {MediaStore.Images.Media.DATA};
  
                  Cursor cursor = getContentResolver().query(selectedImage,
                          filePathColumn, null, null, null);
                  cursor.moveToFirst();
                  int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
                  String picturePath = cursor.getString(columnIndex);
  
  //                String filename = selectedImage.getLastPathSegment();
  
                  String[] filenames = picturePath.split("\\/");
  
  
                  int count = filenames.length;
                  String name = filenames[count - 1];
  
  
                  imagepickerselected = 1;
                  UploadIamgeinServer(1, name);
  
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
  }
  </code></pre>
  
  <p>Choose file getting open whenever i click to choose file in button click. But all files are shown like hidden except images, Click doest work.<a href="https://i.stack.imgur.com/eRdMF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eRdMF.png" alt="enter image description here"></a>  Without method in it button click works fine.  If anyone found errors in code please let me know.</p>
  
  <p>Thanks</p>