I have a directory /sdcard/audio in the project. This directory contains some audio (wav) files.
Here is what I am trying to do:
1. Read from the directory.
2. Play the wav files.
The code I have written for accessing the directory is as follows:
String path_to_media = "/sdcard/audio/";
File dirEffectFiles = new File(path_to_media); //gets a handle to the directory of effect files.
Log.v(this.toString(), "Getting into path = " + path_to_media);
Log.v(this.toString(), "Some details about the directory: path = " + dirEffectFiles.getPath()
+ " Can read: " + dirEffectFiles.canRead() + " list:" + dirEffectFiles.list()
+ " absolute path:" + dirEffectFiles.getAbsolutePath() + " is absolute:" + dirEffectFiles.isAbsolute());
The output I get for the above is:
01-13 16:23:34.941: Some details about the directory: path = /sdcard/audio Can read: false list:null absolute path:/sdcard/audio is absolute:true
I have the following questions:
1. How can I make the above folder readable? By setting dirEffectFiles.setReadable(true)
?
2. Also, please note that path_to_media
above is /sdcard/audio/. When it is printed, the last "/" disappears. Is that a normal effect of some internal parsing or should I be worried about that??
Any help is most welcome,
Thanks,
Sriram.
/sdcard/audio referred to above was a directory made in the project directory. This approach is wrong. The directory for emulating the sdcard must be created using adb (in command prompt (windows))like so:
adb shell mkdir /sdcard/audio
- this will create the audio/ sub-directory in sdcard/ adb push "complete path of file name to be pushed" /sdcard/audio/file-name
That's it. You should be able to read files from the mounted /sdcard directory.
@thoredge: thanks for your help.