assets文件夾資源的訪問assets文件夾裏面的文件都是保持原始的文件格式,需要用AssetManager以字節流的形式讀取文件。
先在Activity裏面調用getAssets()來獲取AssetManager引用。
再用AssetManager的open(String fileName, int accessMode)方法則指定讀取的文件以及訪問模式就能得到輸入流InputStream。
然後就是用已經open file 的inputStream讀取文件,讀取完成後記得inputStream.close()。
4.調用AssetManager.close()關閉AssetManager。