Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filenotfound exception from assets folder android?

Tags:

android

While reading from file under Assets/sb/example/simple.html/It is giving filenotfound exception.

11-01 18:30:13.562: WARN/System.err(912): java.io.FileNotFoundException: file:///android_asset/sb/example/simple.html

Code Snippet is

try {
    final AssetManager assetMgr = ctx.getResources().getAssets(); 
    is = assetMgr.open(path, AssetManager.ACCESS_STREAMING);
    // is = getAssets().open(file.getAbsolutePath());
} catch (IOException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
}
like image 232
ADIT Avatar asked Nov 21 '25 03:11

ADIT


1 Answers

Here I had given full path of the asset folder but in assets it takes relative path.

 try { 
     final AssetManager assetMgr = ctx.getResources().getAssets();  
     is = assetMgr.open("sb/example/simple1.html"); 
 } catch (IOException e1) { 
     // TODO Auto-generated catch block 
     e1.printStackTrace(); 
 } 

It is working....

like image 57
ADIT Avatar answered Nov 23 '25 18:11

ADIT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!