首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >内存读写

内存读写
EN

Stack Overflow用户
提问于 2017-12-10 18:17:52
回答 0查看 82关注 0票数 0

setDestinationInExternalFilesDir( this,"/download","app-debug.apk");为什么要保存在内部存储中?

为什么找不到包含/data/data/com.example.xxx/files/download/app-debug.apk的已配置根目录

代码语言:javascript
运行
复制
 downloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
Uri uri = Uri.parse("http://");
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setDestinationInExternalFilesDir(this, "/download", "app-debug.apk");
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
Long reference = downloadManager.enqueue(request);

File imagePath = new File(getFilesDir(), "download");
File newFile = new File(imagePath, "app-debug.apk");
CharSequence text1 = "no file";
Toast toast1 = Toast.makeText(getApplicationContext(), newFile.getAbsolutePath()+"can't find file ", Toast.LENGTH_SHORT);

if(!newFile.exists()){toast1.show(); return false;}
Uri uri2 = FileProvider.getUriForFile(this,"com.example.xxx",newFile);
Intent i = new Intent();
i.setAction(android.content.Intent.ACTION_VIEW);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setData(uri2);
i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
i.setType("application/vnd.android.package-archive");
startActivity(i);

提供程序路径

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<!--<external-path name="external_files" path="."/>-->
<files-path
 name="tlumacz1"
path="download"/>
</paths>

清单

代码语言:javascript
运行
复制
 <provider
        android:name="android.support.v4.content.FileProvider"
        android:authorities="com.example.xxx"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/provider_paths"/>
    </provider>

mby在内部存储器中有外部存储器或类似的东西吗?

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47737819

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档