2011-05-25 126 views
0

我已將我的靜態web應用程序放置在資源文件夾中。我的靜態Web應用程序有很多文件夾並放置在資源文件夾中。我從另一個HTML與子文件夾中調用HTML。我正在'找不到文件'。有人可以告訴我問題是什麼嗎?我下面張貼我的代碼:在android的webview中找不到文件

wv=(WebView)findViewById(R.id.webView); 
     //wv.loadDataWithBaseURL("file:///android_asset/Opana_Changes/html/_assets/asset_001/index.html","","html"); 

     try { 
     InputStream is=getAssets().open("Opana_Changes/index.html"); 
     BufferedReader br=new BufferedReader(new InputStreamReader(is)); 
     String line = null; 
     while ((line = br.readLine()) != null) { 
      html=html+line; 
     } 
     br.close(); 

    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 

      wv.loadDataWithBaseURL("file:///android_asset/Opana_Changes/",html,"text/html", "UTF-8",null); 


     wv.getSettings().setJavaScriptEnabled(true); 
     } 

回答

3

嘗試下面的代碼,如果你的HTML文件的資產文件夾意味着資產有Opana_Changes文件夾和Opana_Changes你有你的HTML文件。它會工作。

wv=(WebView)findViewById(R.id.webView); 

wv..loadUrl("file:///android_asset/Opana_Changes/index.html"); 

如果我的回覆對您有幫助,請不要忘記投票。

file:///android_asset gives you path upto assets folder. 

你可以給您的文件所在

感謝 迪帕克

確切的文件夾結構
相關問題