Android : Saving Files to SD Card(Android : 将文件保存到 SD 卡)
问题描述
我正在尝试将我的应用程序中的文件保存到设备的外部存储中.具体来说,我正在尝试保存声音.
I am trying to save a file out from within my app to the external storage of a device. Specifically, I am trying to save a sound out.
我已经按照每个教程"进行此操作,没有一个对我来说特别令人困惑,但它对我不起作用.根本不会在 SD 卡上创建文件,更不用说实际传输信息了.
I've followed every 'tutorial' on doing this, and none of it seemed particularly confusing to me, yet it just will not work for me. No file is ever created on the SD card at all, much less actually transferring over the information.
我假设我没有得到正确的卡片路径,但无论我尝试了什么,它都不起作用.我尝试只输入/sdcard/",以及使用 getExternalStorageDirectory() 方法,以及其他随机实验.
I've assumed I am somehow not getting the correct path to the card, but no matter what I have tried it doesn't work. I have tried entering just "/sdcard/", as well as using the getExternalStorageDirectory() method, among other random experiments.
花了半天多的时间在一些看起来如此微不足道的事情上,我什至无法再思考了,所以我希望你能原谅我提供的一些缺乏细节,但任何建议都会对此有所帮助点.
After spending over half the day on something that would seem so trivial I can't even think straight anymore, so I hope you will excuse some of the lack of detail I'm providing, but any suggestion would be helpful at this point.
推荐答案
您确定文件没有保存到 SD 卡吗?我以为我遇到了同样的问题.事实证明,我一直正确地保存到 SD 卡,但画廊没有被刷新以显示我刚刚保存的文件.使用 Astro 文件管理器确保文件尚未保存到卡中.如果这是问题所在,请添加此行以刷新图库:
Are you absolutely certain the file isn't being saved to the SD card? I thought I was having the same problem. It turned out that I was saving correctly to the SD card the whole time, but the gallery wasn't being refreshed to show the files I had just saved. Use Astro File Manager to make sure the file isn't already being saved to the card. If this is the problem, add this line to refresh the gallery:
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"
+ Environment.getExternalStorageDirectory())));
这篇关于Android : 将文件保存到 SD 卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android : 将文件保存到 SD 卡
基础教程推荐
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01