Reputation: 457
i want to show the filename from the full path. i m getting the full path but don't know how to get that file name with extension? please show me by some example.
code which i use to get full path of the file:
if (resultCode == Activity.RESULT_OK) {
Log.i("On onActivityResult", "get path");
Uri selectedVideoUri = data.getData();
try {
String filemanagerstring = selectedVideoUri.getPath();
String selectedVideoPath = getPath(selectedVideoUri);
if (selectedVideoPath != null) {
filePath = selectedVideoPath;
Log.i("VideoFilePath", "" + filePath);
} else if (filemanagerstring != null) {
filePath = filemanagerstring;
Log.i("FilePath", "" + filePath);
} else {
Toast.makeText(getApplicationContext(), "Unknown path",
Toast.LENGTH_LONG).show();
Log.e("Bitmap", "Unknown path");
Log.i("FilePath", "" + filePath);
}
Upvotes: 0
Views: 11515
Reputation: 10083
Try this, where path
is the entire filename including parent directories:
path.getName()
Upvotes: 3