从资源文件夹android找到Filenotfound异常?

时间:2010-11-01 13:02:27

标签: android

从Assets / sb / example / simple.html /下的文件中读取它正在给出filenotfound 异常。

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

代码段是

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();
}

1 个答案:

答案 0 :(得分:4)

这里我给出了资产文件夹的完整路径,但在资产中它采用了相对路径。

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

它正在运作......

相关问题