Friday, June 10, 2011

How to read the assets directory resources - Andriod


1. Get the input stream resource


Resource file sample.txt at $ PROJECT_HOME / assets / directory, can be adopted in the Activity

Context.getAssets (). Open ("sample.txt")

Method to obtain input stream.

Note: If the resource file is a text file that you need to consider file encoding and line breaks. Recommend the use of UTF-8 and Unix line breaks.

2. WebView load the assets directory html files


Resource file sample.html at $ PROJECT_HOME / assets / directory, the following code can be

WebView.loadUrl ("file: / / / android_asset / sample.html");

Load html file.

No comments:

Post a Comment