title: I want convert 'content://0@media/external/file/147' to file:///storage/sdcard0/files/X.pdf` in android?
body: <pre><code>Uri fileUri = getIntent().getData();
          if (!fileUri.getPath().contains("external") &amp;&amp; fileUri.getScheme().equals("content")) {
              Cursor cursor = getContentResolver().query(fileUri, null, null, null, null);
              try {
                  if (cursor != null &amp;&amp; cursor.moveToFirst()) {
                      fileName = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
                  }
              } finally {
                  cursor.close();
              }
          }if (!fileUri.getPath().contains("external") &amp;&amp; fileUri.getScheme().equals("file")) {
              List&lt;String&gt; pathSegments = fileUri.getPathSegments();
              if (pathSegments.size() &gt; 0) {
                  fileName = pathSegments.get(pathSegments.size() - 1);
              }
          }
  </code></pre>