Android Notes 74: How to extract filename from Uri?

Hey,
Firstly, please check these articles :

Android Notes 72: How to convert Bitmap to Uri?

Hey,

freakycoder.com

Android Notes 73: How to get Real Path from Uri?

Hey,

freakycoder.com

Now, we can extract filename with and without extension :)
You will convert your bitmap to uri and get the real path of your file. Now we have a path.
Here is how to extract filename :
Markdown:
Uri uri = getImageUri(bitmap);
String path = getRealPathFromURI(uri);
String filename = path.substring(path.lastIndexOf("/")+1);
String file;
if (filename.indexOf(".") > 0) {
    file = filename.substring(0, filename.lastIndexOf("."));
} else {
    file =  filename;
}
Log.d(TAG, "Real Path: " + path);
Log.d(TAG, "Filename With Extension: " + filename);
Log.d(TAG, "File Without Extension: " + file);
Gist:
If you have any question, ask me :)
Have fun !

How to extract filename from Uri?

Now, we can extract filename with and without extension :) You will convert your bitmap to uri and get the real path of your file. Now w...