2011-12-13 49 views
4

我想在我的应用程序的内部存储器中创建一个文件夹来存储音频文件,然后检查是否存在做某些操作。 如何制作这个文件,在哪个路径中,以及如何重新检索这些文件?在内部存储器中创建文件夹以保存文件并稍后检索

+4

阅读[此](http://developer.android.com/guide/topics/data/data-storage.html#filesInternal),然后在你的问题中添加一些代码。 – Phil 2011-12-13 17:42:47

回答

10
File mydir = context.getDir("mydir", Context.MODE_PRIVATE); //Creating an internal dir; 
File fileWithinMyDir = new File(mydir, "myfile"); //Getting a file within the dir. 
FileOutputStream out = new FileOutputStream(fileWithinMyDir); //Use the stream as usual to write into the file 

对于从内部删除文件:

if (new File("path/to/file").delete()) { 
    // Deleted 
} else { 
    // Not deleted 
} 
+1

thanx ..我试了一下,我看到日志中的路径(/data/data/com.packageName/app_mydir/audio.mp3) 但我想播放音频,但它不断显示我这个错误(机器人。 media.MediaPlayer.prepare(Native Method)) \t in the preparation Method – Reham 2011-12-13 18:56:31

相关问题