Android: Media file Path -
i trying available media on internal storage.
i have created folder "teststorage" in actual phone. pushed song ddms push.
question: file path have mention in java file?.
sample code :
final string media_path = new string("/mnt/shell/emulated/o/teststorage"); public arraylist<hashmap<string, string>> getplaylist() { file musicfolder = new file(media_path); if (musicfolder.listfiles(new fileextensionfilter()).length > 0) { (file file : musicfolder.listfiles(new fileextensionfilter())) { hashmap<string, string> song = new hashmap<string, string>(); song.put("songtitle",file.getname().substring(0,(file.getname().length() - 4))); song.put("songpath", file.getpath()); // adding each song songlist songslist.add(song); } } // return songs list array return songslist; }
this path can see in ddms file explorer, in same case see path
"/storage/emulated/o/teststorage"
in file explorer inside phone.
now 1 mention in code list. tried both not listing song.
what wrong doing there.
try below
file file= new file(android.os.environment.getexternalstoragedirectory()+"/emulated/o/teststorage");
also use file.seperator
instead of /
http://developer.android.com/guide/topics/data/data-storage.html#filesexternal
check topic under accessing files on external storage
Comments
Post a Comment