Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem while opening Asset File with the help of Content Provider
    text
    copied!<p>My requirement is to open one app's Asset file from another app via content provider.(I am exposing that file with ContentProvider implementation)</p> <p>I am able to open few files and read, but while opening some files I am getting exception. Please find the implementation for opening Asset File.</p> <pre><code>@Override public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { AssetManager am = getContext().getAssets(); String file_name = uri.getLastPathSegment(); if(file_name == null) throw new FileNotFoundException(); AssetFileDescriptor afd = null; try { afd = am.openFd(file_name); } catch (IOException e) { e.printStackTrace(); } return afd;//super.openAssetFile(uri, mode); } </code></pre> <p>Some times, <code>am.openFd(file_name);</code> is throwing an exception saying that,</p> <pre><code>java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed at android.content.res.AssetManager.openAssetFd(Native Method) at android.content.res.AssetManager.openFd(AssetManager.java:329) at com.pineone.swfinstaller.SwfProvider.openAssetFile(SwfProvider.java:25) at android.content.ContentProvider$Transport.openAssetFile(ContentProvider.java:218) at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:234) at android.os.Binder.execTransact(Binder.java:288) at dalvik.system.NativeStart.run(Native Method) </code></pre> <p>But, the same file I can open in my PC or even in Android device in some other manner.</p> <p>Can anyone point out me, in what scenarios, we will get this exception.</p> <p>Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload