Search code examples
androidxamarinxamarin-studioxamarin.android

Android Assets Manager Exception


I wanted to use Android Assets and followed the tutorial in the official docs.

Have set the asset type to AndroidAssets like it says, but it was throwing exceptions for not finding the file. I have a rooted device so upon inspection I noticed that the files are not actually on the device at all (/data/data/com.company.application/files/SomeFile.txt).

EDIT:

String filename = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "AboutAssets.txt");
FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);

Solution

  • Posted this a while ago and ended up not using Xamarin because I never found a solution. I have recently come back to Xamarin and the latest updates seem to have fixed this issue - the same project now works fine with no changes made.

    So if anyone else encounters this - try updating.