0
如何在我的代码中指定我自己的下载文件夹路径?如何指定外部存储路径?
路径:
static File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
static File ApkFileDirectory = new File(dir, "update.apk");
代码:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(
Uri.fromFile(new File(Environment
.getExternalStorageDirectory()
+ "/download/"
+ "update.apk")),
"application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
我想在我的代码使用ApkFileDirectory
。
我试过,但我得到错误“无法解析构造”
` Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(
Uri.fromFile(new File(ApkFileDirectory),
"application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);`
试试这个:'公共静态最后弦乐ApkFileDirectory = Environment.getExternalStorageDirectory()getAbsolutePath() +文件分割符+“下载”;' –