SQLite & local data
Understand tables, queries, parameters, and cursors.
A schema describes your data
A table contains rows, and each column has a purpose. A primary key identifies a row.
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
title TEXT NOT NULL
);Keep values separate from SQL
Use bound parameters or ContentValues instead of concatenating user input into a SQL statement. This keeps the value from becoming SQL syntax.
Database work can block
Open and query databases off the UI thread where appropriate. Close cursors and define a migration when you change an existing schema.
Try it yourself
Design a notes table with a completed flag. Write the query to list only incomplete notes.


