title: how to get the path of selected PDF/doc from file manager in android programmatically
body: <p><strong>I have written this code to open my Document manager and select any PDF/Doc file.</strong></p>
  
  <pre><code>Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
              intent.addCategory(Intent.CATEGORY_OPENABLE);
              intent.setType("*/*");
              Intent i = Intent.createChooser(intent, "File");
              startActivityForResult(i, 1);
  </code></pre>
  
  <p><strong>When I select any Pdf/Doc file I am unable to get path of that select file.</strong></p>
  
  <p><strong>I tried this code also but it give me null as output</strong></p>
  
  <pre><code>protected void onActivityResult(int requestCode, int resultCode,
          Intent intent) {
      if (requestCode == 1) {
          if (resultCode == RESULT_OK) {
              Uri uri = intent.getData();
              String fileImagePath = getRealPathFromURI(uri);
              String type = intent.getType();
  
              Log.d("Hello", fileImagePath + "");
              if (uri != null) {
                  String path = uri.toString();
                  if (path.toLowerCase().startsWith("file://")) {
                      // Selected file/directory path is below
                      path = (new File(URI.create(path))).getAbsolutePath();
                      Log.d("Hel", path);
                  }
  
              }
          } else
              Log.d("Hello", "Back from pick with cancel status");
      }
  }
  
  
  
  
  public String getRealPathFromURI(Uri uri) {
      String[] projection = { MediaStore.Files.FileColumns.DATA };
      Cursor cursor = managedQuery(uri, projection, null, null, null);
      int column_index = cursor
              .getColumnIndexOrThrow(MediaStore.Files.FileColumns.DATA );
      cursor.moveToFirst();
      return cursor.getString(column_index);
  }
  </code></pre>
  
  <p>Please help me thanks in advance.</p>