问题
I want to get fileName from a uri... I can get a fullpath from Other apps like gallery or other third party file managers, but I can't get fileName from KitKat Document, I don't need a fullPath just the fileName with an inputStream is good for me...
Thanks
Edit: I found a piece of code that solves the issue almost, but it can't get filePath of none known types like *.exe *.vcf , ...
Here's the source
回答1:
If you have the absolute path of file then simpley create the object of file and use getName method
File f = new File(<Full Path of your file>);
This will return file name with extension.
ANd if you do not want extension then use CommonsI/O libarary
And from that library you can use
String fileNameWithOutExt = FilenameUtils.removeExtension(fileNameWithExt);
来源:https://stackoverflow.com/questions/22068393/get-filename-from-uri-on-kitkat-document