public static List <string> GetAssetPathList(Context context) { try { List <string> assetList = new List <string>(); using (IAssetPackManager assetPackManager = AssetPackManagerFactory.GetInstance(context)) { IDictionary <string, AssetPackLocation> assetPackLocations = assetPackManager.PackLocations; if (assetPackLocations != null) { foreach (KeyValuePair <string, AssetPackLocation> location in assetPackLocations) { assetList.Add(location.Value.AssetsPath()); } } } return(assetList); } catch (Exception) { // ignored } return(null); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); Toolbar toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab); fab.Click += FabOnClick; assetPackManager = AssetPackManagerFactory.GetInstance(this); listener = new AssetPackStateUpdateListenerWrapper(); listener.StateUpdate += Listener_StateUpdate; var randomStream = Assets.Open("random.txt"); if (randomStream == null) { Android.Util.Log.Info("AssetPackSample", $"Failed to open random.txt"); } else { Android.Util.Log.Info("AssetPackSample", $"Loaded random.txt"); } }