1。獲取資源的輸入流
資源文件 test.txt 位於 $project_home/assets/ 目錄下,能夠在 Activity 中經過
(a)Context.getAssets().open(「test.txt」);html
(b)AssetManager assetManager = getAssets();
InputStream is = assetManager.open("jin.txt"); android
方法獲取輸入流。 注意:若是資源文件是文本文件則須要考慮文件的編碼和換行符。建議使用UTF-8。 2. WebView 加載assets目錄下的html文件 資源文件 sample.html 位於 $PROJECT_HOME/assets/ 目錄下,能夠經過如下代碼 WebView.loadUrl(「file:///android_asset/sample.html」); 加載html文件