Skip to content

Instantly share code, notes, and snippets.

@chittaranjan-khuntia
Created June 24, 2016 09:25
Show Gist options
  • Save chittaranjan-khuntia/3893e8f0dbc03d4f6aac197036d57c68 to your computer and use it in GitHub Desktop.
Save chittaranjan-khuntia/3893e8f0dbc03d4f6aac197036d57c68 to your computer and use it in GitHub Desktop.
how to get full path of a file inside sdcard in Android?
protected void onActivityResult(int requestCode, int resultCode, Intent intent)
{
if (requestCode == PICK_REQUEST_CODE)
{
if (resultCode == RESULT_OK)
{
Uri uri = intent.getData();
String type = intent.getType();
LogHelper.i(TAG,"Pick completed: "+ uri + " "+type);
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();
}
}
}
else LogHelper.i(TAG,"Back from pick with cancel status");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment