Search code examples
androidandroid-sdcardandroid-contentresolver

How to convert File path to Content Uri in Android?


I am going on with my surfceview in that i had stored the image in SDCard by seperate folder by File path from that how to get MimeType it set the type as NULL.

How can i get the MimeType from local file path but by default calling the intent i can get the MimeType .

For that tried to convert the File path to Content Uri but no changes if someone have idea about this please help me friends.


Solution

  • Here is the solution to get MimeType from Filepath:

      String extention =  stringUri.substring(stringUri.lastIndexOf("/"));
                String mimeTypeMap = MimeTypeMap.getFileExtensionFromUrl(extention);
                String mimeType = MimeTypeMap.getSingleton()
                        .getMimeTypeFromExtension(mimeTypeMap);