[英]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. 您可以将图像保存为res / drawable,将声音文件保存为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. 如果您确实想为声音和图像文件创建一个单独的文件夹,则可以在SD卡上创建它。 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();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.