0

The project is a quiz app in xamarin forms using SqLite, in the code there needs to be a way to load the questions, I will show how they do it in Azure, I need to do the same thing but in SqLite. I have also included a link to the source code for the xamarin quiz using Azure. [1]: https://github.com/garudaslap/xamarinquiz

    public async Task LoadQuestions()
    {
        IsLoading = true;
        MobileServiceClient client = AppSettings.MobileService;

        IMobileServiceTable<XamarinQuiz> xamarinQuizTable = 
        client.GetTable<XamarinQuiz>();

        try
        {
            QuestionList = await xamarinQuizTable.ToListAsync();
        }
        catch (Exception exc)
        {
        }


        IsLoading = false;
        ChooseNewQuestion();
    }

1 Answers1

0

You can use SQLite with this plugin:

https://learn.microsoft.com/en-us/xamarin/xamarin-forms/data-cloud/data/databases

Then your code will be something like:

public async Task LoadQuestions()
{
    IsLoading = true;
    SQLiteAsyncConnection connection = new SQLiteAsyncConnection(dbPath);

    // if you need to create the table
    connection.CreateTableAsync<XamarinQuiz>().Wait();

    try
    {
        QuestionList = await database.Table<XamarinQuiz>().ToListAsync();
    }
    catch (Exception exc)
    {
    }


    IsLoading = false;
    ChooseNewQuestion();
}