On 10月28日, 下午11时00分, Russell Stewart <[email protected]> wrote:
> I have been developing for Android for quite a while now, but for the first
> time I am going to be bundling a few custom notification sounds with my
> app. I am curious if there is any standard practice for making those sounds
> available to the user?
>
> I currently have the mp3 files in in the "assets" directory, under a new
> directory called "sounds". I know that Android normally stores extra
> ringtones on the SD card in the path media/audio/ringtones. Should I just
> extract the files there? Or is there somewhere else that is a better choice?
You can through iterator the SD card find all of the files endwith mp3
and 3gp.
just like:
String SDPath = Environment.getExternalStorageDirectory()
+File.separator;
getFiles(SDPath);
private void getFiles(String url) {
File[] files = new File(url).listFiles();
for(int i=0;i<files.length;i++) {
if(files[i].isDirectory()) {
getFiles(files[i].getAbsolutePath());
}else {
if(files[i].getAbsolutePath().endsWith(".mp3")||
files[i].getAbsolutePath().endsWith(".3gp")||
files[i].getAbsolutePath().endsWith(".wma")) {
//Save to list and returns
.....
}
}
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en