0

I found an idea here: Using an AssetManager for resource loading at run time

How can I implement it? Kindly could somebody help me with more information?

Thanks in advance.

Community
  • 1
  • 1
ichernob
  • 357
  • 2
  • 13

1 Answers1

0

Ex: Place your text file in the /Assets ... /Assets/example.txt

public class ReadAsset : Activity
{
protected override void OnCreate (Bundle bundle)
{
    base.OnCreate (bundle);

    InputStream input = Assets.Open ("my_asset.txt");
}
}  

Or you can also put the file in the /Resources/raw... /Resources/raw/example

InputStream is = getResources().openRawResource(R.raw.example);

Or you can load html from asset and load in webview:

 webview.loadUrl("file:///asset/aboutcertified.html"); 

Additionally, some Android functions will automatically load asset files:

/Assets/fonts/samplefont.ttf

Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");

For more information: https://developer.android.com/reference/android/content/res/AssetManager.html

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
alberto basoli
  • 286
  • 2
  • 9
  • I meant loading language resources not from values, but from any downloaded file with an AssetManager – ichernob Sep 22 '15 at 08:53
  • Its not possible with AssetManager because, its created for loading file from assets/Resources. you could download and read/write file in private context of application – alberto basoli Sep 22 '15 at 10:53
  • See this example: http://jmsliu.com/1954/android-save-downloading-file-locally.html – alberto basoli Sep 22 '15 at 11:00