简体   繁体   中英

Is it possible to create a separate folder for keeping images and sounds

嗨,我需要将图像及其声音保存在res文件夹结构内的单独文件夹中。之后,我需要从该文件夹读取并显示图像到我的应用程序中,请回复

是的 ,您可以在res文件夹(res / raw)中创建一个名为raw的单独文件夹,并将可绘制内容和声音保留在该文件夹中。

You can save your images to res/drawable and your sound files to res/raw.

If you really want to create a separate folder for your sound and image files, you can create it on your SD Card. Please see the example codes below:

File fileList= new File("/sdcard/MyFiles/");
//Store the file names within MyFiles folder to pathList[]
pathList = fileList.list();

//Create the URI path of your files here
StringBuilder sb = new StringBuilder();
sb.append("/sdcard/MyFiles/"+pathList[index1]);
pathList[index1]=sb.toString();

//Here is how you can play your sound files
MediaPlayer mp = new MediaPlayer();
mp.setDataSource(PATH_TO_FILE);
mp.prepare();
mp.start();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM