Search code examples
androidfilesystemsxamarinxamarin.androidmonodevelop

Xamarin Android: add custom files to apk during build


i need to add some files to be accessed by deployed android application for test purposes (they will be downloaded from internets later). particularly, i need files in cache directory for application to see them

is there any way to add them there at build time?

or any time at all. i can't even add them to apk\cache with android debug monitor! (it says Failed to push the items)

is it really the only way to do it is download them from internet i wonder.. o_O


Solution

  • You could use the Assets folder

    Any raw assets you want to be deployed with your application can be placed in this directory (and child directories) and given a Build Action of "AndroidAsset".

    These files will be deployed with you package and will be accessible using Android's AssetManager, like this:

    public class ReadAsset : Activity
    {
        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);
            InputStream input = Assets.Open ("my_asset.txt");
        }
    }