samedi 2 janvier 2016

SQLite: Database lock on some devices (.NET)

.NET, PCL on Android (Xamarin)

On a very rare number of Android devices I get a Database Lock error from SQLite when in this code. Is there a way to tell the system to "wait" until the database is ready to insert? (iOS is fine)

    private async Task InsertForLanguage(MySystem data, int languageId)
    {
        await ClearDatabase(languageId);
        await _db.InsertAllAsync(data.XXX);
        await _db.InsertAllAsync(data.TTT);
        await _db.InsertAllAsync(data.RRR);
        await _db.InsertAllAsync(data.EEE);

    }

    private async Task ClearDatabase(int languageId)
    {

        await _db.ExecuteAsync("delete from XXX where Languageid=?", languageId);
        await _db.ExecuteAsync("delete from TTT where Languageid=?", languageId);
        await _db.ExecuteAsync("delete from RRR where Languageid=?", languageId);
        await _db.ExecuteAsync("delete from EEE where Languageid=?", languageId);

    }

Aucun commentaire:

Enregistrer un commentaire