问题描述
我生成我的应用程序,它产生的应自动保存在下载,所有的下载通常保存在任何Android设备的文件夹时excelsheet。
I am generating an excelsheet in my app which when generated should be automatically saved in the "Downloads" folder of any android device where all the downloads are typically saved.
我有在我的文档文件夹中保存文件中的以下 -
I have the following which saves the file under "My Files" folder -
File file = new File(context.getExternalFilesDir(null), fileName);
造成 -
W/FileUtils﹕ Writing file/storage/emulated/0/Android/data/com.mobileapp/files/temp.xls
我宁愿要自动保存生成的文件在下载时生成Excel表格文件夹中。
I rather want to save the generated file automatically in the "Downloads" folder when the excel sheet is generated.
更新#1:请在这里看到的快照。我要的是红色的一个圈,什么你的建议被存储在一个蓝色的圆圈(/存储/模拟/ 0 /下载)如果是有道理的。请指教我如何能保存在一个文件中红色圆圈,即下载文件夹,这是从/存储不同/模拟下MYFILES
Update # 1: Please see the snapshot here. What I want is the one circled in red and what you suggested gets stored in the one circled blue (/storage/emulated/0/download) if that makes sense. Please advise on how I can save a file in the one circled red i.e., "Downloads" folder which is different from /storage/emulated/0/Download under "MyFiles"
推荐答案
现在从你的问题编辑我想更好地了解你想要什么。
在下载菜单上显示从红一盘旋的文件是那些通过实际下载下载管理器
,虽然previos步骤,我给你保存在文件中的下载文件夹,但他们不会在这个菜单中显示,因为他们没有下载。然而,为了使这项工作,你必须启动下载你的文件,因此它可以显示在这里。
Now from your question edit I think understand better what you want.Files shown on the Downloads menu from the one circled in red are ones that are actually downloaded via the DownloadManager
, though the previos steps I gave you will save files in your downloads folder but they will not show in this menu because they weren't downloaded. However to make this work, you have to initiate a download of your file so it can show here.
下面是如何开始下载一个例子:
Here is an example of how you can start a download:
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "fileName");
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); // to notify when download is complete
request.allowScanningByMediaScanner();// if you want to be available from media players
DownloadManager manager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
manager.enqueue(request);
此方法用于从开放的下载,我还没有与当地文件中使用它。
This method is used to download from a Uri and i have not used it with a local file.
如果你的文件是不是来自你可以尝试保存临时副本并获得该值的文件的URI互联网。
If your file is not from the internet you could try saving a temporary copy and get the Uri of the file for this value.
这篇关于如何存储在&QUOT从应用程序生成的文件;下载和QUOT; Android的文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!