SQLite:某些设备上的数据库锁定(.NET)

时间:2016-01-02 20:54:33

标签: android sqlite xamarin

.NET,Android上的PCL(Xamarin)

在极少数的Android设备上,我在此代码中从SQLite收到数据库锁定错误。有没有办法告诉系统“等待”,直到数据库准备好插入? (iOS很好)

    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);

    }

1 个答案:

答案 0 :(得分:0)

您可以使用try catch将代码置于循环中,当数据库就绪时,您的尝试将成功