【发布时间】:2020-12-01 13:07:12
【问题描述】:
我正在创建一个ACTION_SENDIntent,它发送有关设备/应用程序当前状态的不同信息
我无法将共享首选项文件 URI 附加到该意图
Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
intent.setData(Uri.parse("mailto:"));
intent.setType("application/*");
intent.putExtra(Intent.EXTRA_EMAIL , new String[] {"support@example.com"});
intent.putExtra(Intent.EXTRA_SUBJECT, "Email subject");
intent.putExtra(Intent.EXTRA_TEXT, "Email body - Debug info");
// THE IMPORTANT PART
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM,fileUriList);
其中fileUriList 是ArrayList<Uri>,其中包含:
- 我从
ContentProvider成功得到的SQLite数据库文件 - 共享首选项文件 URI - 我无法获取
提供者如何在清单中注册
<provider
android:name="._android._providers.MyFileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
@xml/provider_paths:
<paths>
<cache-path name="cache_internal_storage" path="." />
<external-path name="external_files" path="."/>
</paths>
这就是我尝试获取共享首选项文件的 URI 的方式:
String spFilePath = getApplicationInfo().dataDir + "/shared_prefs/main_sp.xml";
File sharedPrefsMain = new File(spFilePath);
Uri spUri = MyFileProvider.getUriForFile(this, getApplicationContext().getPackageName() + ".provider", sharedPrefsMain);
我收到以下错误消息:
未能找到配置的根目录包含 /data/data/ro.example.example/shared_prefs/main_sp.xml
如何正确地从内部私有内存中获取共享首选项 .xml 文件?
【问题讨论】:
标签: android android-contentprovider