2013-02-22 79 views
0

我已經在我的資產文件夾中包含一些html文件,但是當我嘗試在webview中顯示它們時,我收到文件未找到錯誤。我無法在fileexplorer的// data/data/files文件夾中看到該文件。不知道是什麼問題。誰能幫忙?Android資產文件未顯示。獲取文件未找到錯誤

+0

顯示一些關於如何將它放入你的webview的代碼。資產是我認爲總是在運行時加載(例如沒有R.assets。) – Raigex 2013-02-22 14:48:54

回答

0

我不知道你什麼是VE到目前爲止已經試過,但是這是在運行時得到的資產文件夾中的文件一個正確的方法:

InputStream is = getAssets().open("YourHTML.html"); 
0

我表明,被驅除的幫助文件靜態html文件我把我的資產文件夾。這是我的代碼:

BufferedReader in = null; 
StringBuilder buffer = new StringBuilder(); 

String assetFile = "help.html"; 

try { 

    in = new BufferedReader(new InputStreamReader(getAssets().open(assetFile),"utf-8")); 
    String line; 

    /* line by line read in the file */ 
    while ((line = in.readLine()) != null) buffer.append(line); 

} catch (IOException e) { 
} finally { 
    try { in.close(); } catch (Exception e) {} 
} 

WebView wv = (WebView) findViewById(R.id.help_view); 
wv.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); 
wv.loadDataWithBaseURL(null, buffer.toString(), "text/html", "utf-8",null);