大佬教程收集整理的这篇文章主要介绍了Android:如果我想从Downloads文件夹中查看/选择一个SQLite数据库,那么mime类型是什么?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我在我的下载文件夹中复制了一个sqlite数据库.我试图使用fileIntent.setType(“/”).
谢谢.
File BACkupDB = ...; //Uri uri = Uri.fromFile(BACkupDB); //From Android 7,this line results in a FileUriExposedException. Therefore,we must use MyFileProvider instead... Uri uri = FileProvider.getUriForFile(this,getApplicationContext().getPackagename() + ".com.example.myapp.myfileprovider",BACkupDB); Intent newIntent = new Intent(Intent.ACTION_VIEW); newIntent.setDataAndType(uri,"application/x-sqlite3"); newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); newIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(newIntent);
为了完整性,这是我的MyFileProvider.java类:
package com.example.myapp; import android.support.v4.content.FileProvider; public class MyFileProvider extends FileProvider { }
以下是如何在清单中声明它:
<provider android:name=".MyFileProvider" android:authorities="${applicationID}.com.example.myapp.myfileprovider" android:exported="false" android:grantUriPermissions="true"> <Meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/my_file_provider_paths"/> </provider>
最后,这是我的my_file_provider_paths.xml:
<?xml version="1.0" encoding="utf-8"?> <paths> <external-path name="external_files" path="."/> </paths>
以上是大佬教程为你收集整理的Android:如果我想从Downloads文件夹中查看/选择一个SQLite数据库,那么mime类型是什么?全部内容,希望文章能够帮你解决Android:如果我想从Downloads文件夹中查看/选择一个SQLite数据库,那么mime类型是什么?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。