如何删除使用内置录音机创建的音频文件
我是这个论坛的新手,也是android的新手。抱歉我的英语很差。
我正在为 Android 1.5 编程。在我的应用程序中,我想使用内置录音机录制音频。为此,我正在使用“意图”的操作来启动录音机
"MediaStore.Audio.Media.RECORD_SOUND_ACTION"
。在 onActivityResult()
中,我将新创建的音频文件复制到我的自定义文件夹,例如 /sdcard/myRecordings/sound_1.3gpp
。
现在我想删除录音机创建的原始文件。
在DDMS视图中,我看到文件是在文件夹中创建的 -
"/sdcard/recordingXXXX.3gpp"
文件名包含XXXX;每当我使用录音机录制音频时,这些数字都会发生变化。我在互联网上搜索过,但从未找到有用的解决方案 - “我怎样才能删除这个文件?”或“如何以编程方式获取这些文件的位置?” (因为我在 DDMS 视图中查看它们)
有人建议使用 ContentResolver 通过指定录音机活动返回的 Uri 来删除文件。我已经使用 -
ContentResolver oContentResolver = getContentResolver();
oContentResolver.delete(oUri, null, null);
但仅删除了 Uri 条目,并且文件保留在上述文件夹中。一项建议是启动媒体扫描仪活动。我已经使用 -
sendBroadcast(new Intent(
Intent.ACTION_MEDIA_MOUNTED,
Uri.parse("file://" + Environment.getExternalStorageDirectory())));
我在清单文件中添加了适当的意图过滤器来完成此操作,但是当我启动应用程序时,这会停止模拟器。
谁能对此提供一些见解?任何帮助将不胜感激!
谢谢!
I am newbie to this forum and android as well. Sorry for my weak English.
I am programming for Android 1.5. In my application, I want to record an audio using built-in sound recorder. For this, I am starting a sound recorder using action -
"MediaStore.Audio.Media.RECORD_SOUND_ACTION"
for an Intent. In onActivityResult()
, I had copied the newly created audio file to my custom folder e.g. /sdcard/myRecordings/sound_1.3gpp
.
Now I want to delete the original file created by sound recorder.
In DDMS view, I had seen that files were created in a folder -
"/sdcard/recordingXXXX.3gpp"
The file name contains XXXX; these are digits that will change every time whenever I am recording audio using sound recorder. I have searched the Internet, but have never found a helpful solution for - "how can I delete this file?" or "how can I get the location of these files programmatically?" (as I am viewing them in DDMS view)
Someone suggested to use ContentResolver
to delete file by specifying the Uri returned by sound recorder activity. I had done this using -
ContentResolver oContentResolver = getContentResolver();
oContentResolver.delete(oUri, null, null);
But only the Uri entry is deleted and the file remains in the folder mentioned above. One suggestion was to start media scanner activity. I had done this using -
sendBroadcast(new Intent(
Intent.ACTION_MEDIA_MOUNTED,
Uri.parse("file://" + Environment.getExternalStorageDirectory())));
I have added the appropriate intent filter in manifest file, but this stops the emulator when I start my application.
Can anyone give some insight on this? Any help will be greatly appreciated!
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论