Is there a function to get the directory part of a file path?
so from
String a="/root/sdcard/Pictures/img0001.jpg";
you get
"/root/sdcard/Pictures"
Is there a function to get the directory part of a file path?
so from
String a="/root/sdcard/Pictures/img0001.jpg";
you get
"/root/sdcard/Pictures"
You could also use FilenameUtils from Apache. It provides you at least the following features for the example C:\dev\project\file.txt:
A better way, use
getParent()
fromFile
Class..http://developer.android.com/reference/java/io/File.html#getParent%28%29
Yes. First, construct a
File
representing the image path:If you're starting from a relative path:
Then, get the parent:
Or, if you want the directory as a
File
object,I have got solution on this after 4 days, Please note following points while giving path to File class in Android(Java):
mention permissions in Manifest file.
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
e.g.