I want to get the absolute path of a file which is selected from a file chooser.
My OnActivityesult()
is like below:
if(resultCode == RESULT_OK) {
switch(requestCode) {
case 1:
Uri pathUri = data.getData();
File userFile = new File(pathUri.getPath());
IMG_PATH = userFile.getParentFile().getAbsolutePath();
Snackbar.make(getCurrentFocus(), IMG_PATH, Snackbar.LENGTH_SHORT).show();
ShowConfirmation(IMG_PATH);
break;
}
}
but this code returns like /document/primary:miniclipId.txt
.
I need the real path like mnt/sdcard1/miniclipId.txt
.
The user will choose .img
file from sdcard or internal.
Can anybody tell me how can i get the path string like that?