App Development8
App Development8
Sameeha moogab
2024
Outline
• Local data persistence
• SQLite
Introduction
• Local data persistence is the process of storing data
on a local device, such as a phone or tablet. This data
will remain on the device even after the app is closed
or the device is restarted. It is important for mobile
apps because it allows apps to store user data, such
as settings, login data, or game data.
How Server Database works
• The stored data can be accessed again by the app at
any time, even when the device is not connected to
the internet. Flutter offers various methods to
perform local data persistence, such as:
● Key-value storage
● File storage
● Database
Key-value storage
Key-value storage is the simplest method of storing data. Data
is stored in the form of keyvalue pairs, where the key is a string
and the value can be any data type.
SQLite
• This makes it ideal for applications that require quick access to data,
such as mobile applications. SQLite is a relational database, which
means that data is stored in tables consisting of rows and columns.
• Each row represents one record, and each column represents one
attribute of that record. SQLite provides various standard RDBMS
features, such as:
o CREATE TABLE : Creates a new table.
o INSERT INTO : Adds new data to a table
o SELECT : Retrieves data from a table.
o UPDATE : Changes the data in the table.
o DELETE : Deletes data from a table.
sqflite package
sqflite package is one of the flutter packages that provides an
interface to the SQLite database, a lightweight and widely used
database engine embedded in most mobile operating systems.
Key concepts used in the sqflite package are as follows:
Database : A collection of organized data stored on the device.
Tables : Structures within a database that hold related data in rows
and columns.
Columns : Represent a specific attribute of the data, having a name
and a data type.
Rows : Individual records within a table, each containing values for
the table's columns.
sqflite package
The core functionality provided by sqflite package is as follows :
1. Import the package
import 'package:sqflite/sqflite.dart';