1

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

M. Reza Nasirloo
  • 16,434
  • 2
  • 29
  • 41

1 Answers1

0

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);
Hardik Trivedi
  • 5,677
  • 5
  • 31
  • 51