Search code examples
c#databasesqliteuwpruntime-error

UWP SQLite error: "attempt to write a read-only database"


im building an UWP application in Visual Studio 2019. In this project i have created a database using DBBrowser.

I can read everything from this database without any problems but when i try to write some data to it, it gives me the error. (attempt to write a read-only database)

Can anyone help me with this issue, i've been working on this for hours and can't find a solution... I've tried changing the security properties of the database. I've recreated the database etc.

These are the properties of the database file

Here is the layout of the project files

Here is the code that i use to write the data to the database file


Solution

  • UWP has very strict file access permissions. I would suggest reading the File access permissions docs, and the following SO threads:

    TL;DR you should put your database in the ApplicationData folder.