Removing image/file name from path in android

android, relative-path

Solution

Use this:

String path = new File(name).getParent();

Problem

I have selected a file from a folder on the SD card, now I want to get that path without the file name attached, here is the code to how I am doing it: ``` currImageURI = data.getData(); String name=getRealPathFromURI(currImageURI); ``` now name stores all the path like /mnt/sdcard/images/photo1.jpg. I want to remove photo1.jpg form this path, need help with this aspect thanks.

Original source