Split path name in android

android

Solution

Although the `split` examples will work, perhaps using the `File` class is arguably "better", just in case you port the code to Windows or MacOS:

String path = "/mnt/sdcard/DNTarie/MalinKundag";
String fileName = new File(path).getName();

Problem

I use Environment to take path from sdcard in android.. I have a folder path: `/mnt/sdcard/DNTarie/MalinKundang` What i want is just take "MalinKundang" (the last name from folder path), how to do that? Thanks..

Original source