答案 0 :(得分:0)
例如:将文本文件放在/ Assets ... /Assets/example.txt
中public class ReadAsset : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
InputStream input = Assets.Open ("my_asset.txt");
}
}
或者您也可以将文件放在/ Resources / raw ... / Resources / raw / example
中InputStream is = getResources().openRawResource(R.raw.example);
或者您可以从资产中加载html并在webview中加载:
webview.loadUrl("file:///asset/aboutcertified.html");
此外,一些Android功能会自动加载资产文件:
/Assets/fonts/samplefont.ttf
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
有关详细信息:https://developer.android.com/reference/android/content/res/AssetManager.html