android - FileProvider.GetUriForFile () throwing Exception. Cannot find configured root -


here code in trying create contenturi can call pdf viewer.

~ provider inside <application> , <authority> matches package name

<provider     android:name="android.support.v4.content.fileprovider"     android:authorities="com.company.fileprovider"     android:exported="false"     android:granturipermissions="true">      <meta-data         android:name="android.support.file_provider_paths"         android:resource="@xml/file_paths"/> </provider> 

~ xml/filepaths.xml

<?xml version="1.0" encoding="utf-8" ?> <paths xmlns:android="http://schemas.android.com/apk/res/android">     <files-path name="assets" path="library/offlineassets/"/> </paths>  

~ .cs have exception

var dir = "/data/data/com.tripleplay_services.triplesport/files/../library/offlineassets/xamarin_documentation1_v1.pdf"; var newfile = new file(dir); if(newfile.exists ()) {     var contenturi = fileprovider.geturiforfile(context, "com.company.fileprovider", newfile); } 

bang!

failed find configured root contains /data/data/com.company/library/offlineassets/xamarin_documentation1_v1.pdf

i'm doing book. stuck , cannot continue.

here exception thrown. have no idea in mroots.entryset() in order crash app.

so after reading source code found provider trying match /data/data/com.package/files/library/offlineassets /data/data/com.package/../library/offlineassets

so understanding file directory android wasn't correct.

make sure whatever directory have saved files in after data/data/com.package/files/ matches in <files-path> path attribute.

~ updated <files-path>

<files-path name="assets" path="../library/offlineassets/" />


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -