FileProviderを使用して電子メールでSQLデータベースファイルを共有しようとしています。Android:FileProvider "設定済みのルートを見つけることができませんでした"
エラー:
java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/com.columbiawestengineering.columbiawest/databases/testresults.db
マイコード:
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<files-path name="test_results" path="databases/"/>
</paths>
たManifest.xml:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.columbiawestengineering.columbiawest"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
Java.code:
File goob = this.getDatabasePath("testresults.db");
Log.d("LOG PRINT SHARE DB", "File goob..? getDatabasePath.. here it is: " + goob.toString());
Uri contentUri = FileProvider.getUriForFile(this, "com.columbiawestengineering.columbiawest", goob);
Log.d("LOG PRINT SHARE DB", "contentUri got: here is contentUri: " + contentUri.toString());
はまた、goobためLogcatは正しいデシベルの場所を示しています
....../com.columbiawestengineering.columbiawest D/LOG PRINT SHARE DB: File goob..? getDatabasePath.. here it is: /data/data/com.columbiawestengineering.columbiawest/databases/testresults.db
任意のヘルプ?
developer.androidから、xml files-path ...はファイル/サブディレクトリを表しているようです。しかし、それはファイルが格納されている場所ではありません。私は迷っている。
おかげCommonsWare、それは私が恐れていたものです...他のはありますデータベースファイルを取得する方法?私はそれを文字列に印刷して文字列をメールで送ることができますが、実際のデータベースファイルを電子メールで送信しようとしています。 –
@DanLehto: 'Context'の[' getDatabasePath() '](http://developer.android.com/reference/android/content/Context.html#getDatabasePath(java.lang.String))はあなたに' File'オブジェクトがデータベースを指しています。 'FileProvider'の目的のために、ファイルのコピーを' getFilesDir() 'または' getCacheDir() 'に作ることは大歓迎です。その時点でデータベースが使用されていないことを確認してください。または、数日後に[私の 'StreamProvider'](https://github.com/commonsguy/cwac-provider)にアップデートして、あなたのデータベースを直接提供できるように拡張する必要があります。 – CommonsWare