Android 资产文件夹中的 Filenotfound 异常?

ADI*_*DIT 3 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
Run Code Online (Sandbox Code Playgroud)

代码片段是

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();
}
Run Code Online (Sandbox Code Playgroud)

ADI*_*DIT 6

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

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

这是工作....