.NET MAUI › Local Storage & Data

How do you use SQLite for local relational data in MAUI?

Intermediate

Answer

Add the sqlite-net-pcl (or Microsoft.Data.Sqlite) package, create a database file path under FileSystem.AppDataDirectory, define models with attributes, and use an SQLiteAsyncConnection to create tables and run async CRUD. It's the standard choice for structured offline data.
var db = new SQLiteAsyncConnection(
    Path.Combine(FileSystem.AppDataDirectory, "app.db3"));
await db.CreateTableAsync<Note>();
await db.InsertAsync(new Note { Text = "Hello" });
var notes = await db.Table<Note>().ToListAsync();
Real-world example A note-taking app stores entries in SQLite so they're available fully offline and queryable.

Common follow-ups: Where should the db file live? | sqlite-net vs Microsoft.Data.Sqlite?