Forum Xamarin.Android

SQLitePlatformAndroid in a widget crashes

GautamJainGautamJain INMember ✭✭✭


I am creating a Android widget using Xamarin. I have taken the Simple Widget project as a sample:

When I instantiate SQLitePlatformAndroid() class in order to use with Sqlite.Net PCL, it crashes. The same code works from my Android app (Xamarin Forms based).

Can anyone guide please?

Best Answer


  • GautamJainGautamJain INMember ✭✭✭

    @AlanClark Thank you very very much. You answer solved it.

    I was not targeting Android N. Mine was Android M. I am still wondering how setting up my project for Android N actually solved the Sqlite data access problem in the widget. Because the app was accessing Sqlite database. But widget was not. And I never had Nougat SDK on my system.

    Until I saw your answer, I didn't know about the Android N change that was made for sqlite.

    So actually I solved to issues. I made my app compatible with Android N and solved the Sqlite access issue in Widget.

    Here is what I did. Hope someone saves time from my answer too:

    1. Installed Android 7.0 (API 24) SDK. Note: Earlier I had installed Android 7.1.1 (API 25) SDK. But Visual Studio did not detect it. It was still showing that Marshmallows was the latest. But then installing Android 7.0 (API 24) solved it.
    2. I had to use SQLite.Net.Platform.XamarinAndroidN package instead of SQLite.Net.Platform.XamarinAndroid. The former one is specially written to fix the latest sqlite change
    3. Also, I had to reference latest Mono.Data.Sqlite in my projects. In the reference list the name is "System.Data.Sqlite". But internally the name is Mono.Data.Sqlite. This is important. I spent a lot of time to find this.


Sign In or Register to comment.