I need the solution for sdk version 17 or below
this is my method.
public static String getRealPathFromURI_API11to18(Context context, Uri content
path = uri.getPath(); only this line is used for get the path of selected file.
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("application/vnd.ms-excel");
intent.addCategory(Intent.CATEGORY_OPENABLE);
try {
startActivityForResult(
Intent.createChooser(intent, "Select a File to Upload"),
FILE_SELECT_CODE);
} catch (android.content.ActivityNotFoundException ex) {
// Potentially direct the user to the Market with a Dialog
Toast.makeText(getApplicationContext(), "Please install a File Manager.",
Toast.LENGTH_SHORT).show();
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
switch (requestCode) {
case FILE_SELECT_CODE:
if (resultCode == RESULT_OK) {
// Get the Uri of the selected file
Uri uri = data.getData();
// Get the path
try {
path = uri.getPath();
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
break;
}
super.onActivityResult(requestCode, resultCode, data);
}