【发布时间】:2019-07-01 10:38:36
【问题描述】:
我正在做 Android 的任务。
我从 URL 下载文件并保存在 android 手机的内部存储/目录中?我的代码写在下面,但这是外部存储代码,我想要内部存储代码。
public void onClick(View v) {
Toast.makeText(Computer.this,"Please Wait until the file is download",Toast.LENGTH_LONG).show();
downloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
Uri uri = Uri.parse("url");
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
request.setAllowedOverRoaming(false);
request.setTitle("" + "filename" + ".pdf");
request.setVisibleInDownloadsUi(true);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
Long reference = downloadManager.enqueue(request);
request.setDestinationInExternalFilesDir(Environment.DIRECTORY_DOWNLOADS, "/"+ "filename");
refid = downloadManager.enqueue(request);
Log.e("OUT", "" + refid);
这是外部存储代码,但我想保存在Android手机的内部存储中。
【问题讨论】:
标签: java android android-internal-storage