安卓:将文件保存到SD卡 [英] Android : Saving Files to SD Card

查看:128
本文介绍了安卓:将文件保存到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.

我认为我不知何故没有得到正确的路径到卡上,但无论怎样我都试过这是行不通的。我曾尝试只输入/ SD卡/,以及使用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卡上的全部时间,但库没有被刷新,以显示我刚刚保​​存的文件。使用天文文件管理器,以确保文件尚未被保存到卡上。如果是这样的问题,加入这行刷新库:

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())));

这篇关于安卓:将文件保存到SD卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆