Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing image/file name from path in android

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.

like image 664
Zubair Avatar asked Dec 16 '12 08:12

Zubair


1 Answers

Use this:

String path = new File(name).getParent();
like image 114
David Fang Avatar answered Sep 19 '22 11:09

David Fang