Some users asked here for a simple SQLite project as an example to make their first steps in SQLite.
The already existing examples seem beeing somewhat complicated for beginners.
These examples are explained in the B4XSQLiteDatabase Booklet.
Attached three small projects:
- SQLiteLight1
A very simple project with a very simple user interface with following functions:
At the first run the database is empty and the user must add entries.
- Add an entry
- Edit an entry
- Update an entry
- Delete an entry
- Display next and previous entry
- SQLiteLight2
A simple project with some more functions:
A default database is supplied to allow the use of the filter without the need to add many entries.
- Display the database in a table with following functions:
-- Add display the Edit activity to add a new entry
-- Edit display the Edit activity to edit an entry
-- Filter filter the database
-- Set Filter display the Filter activity to set the filter
- Edit
-- Add / Update / Delete
-- First / Previous / Next / Last
- Filter
The database is very simple with four columns :
- ID
- FirstName
- LastName
- City
- SQLiteLight3
Same as SQLiteLight2, all functions are the same.
The differences are the database path, database name, table name, columb number, column names, column alias names and column data types are variables instead beeing hard coded.
It allows also to generate a new database by:
- changing in Globals the values of the variables listed above
- in Activity_Create
-- comment this line : 'File.Copy(File.DirAssets, SQLDateBaseName, SQLDataBasePath, SQLDateBaseName)
-- uncomment this line : CreateDataBase
- SQLiteLight4
Multi table example:
The database has three tables and shows the interaction between these tables.
The tables are intentionnaly kept small with only a few columns to keep a clear overview and show how to handle more than one table.
The interface is kept minimalistic and not all possible mistakes are chaecked to keep the code 'short'.
The code has comments and is, I hope, self explanatory.
EDIT: 2014.04.11
Amended error repoted HERE.
EDIT: 2014.05.04
Added SQLiteLight3
Updated SQLiteLight2
EDIT 2015.10.21
SQLiteLight2 and SQLiteLight3 added the Starter Service.
EDIT 2015.11.26
Added SQLiteLight4
The already existing examples seem beeing somewhat complicated for beginners.
These examples are explained in the B4XSQLiteDatabase Booklet.
Attached three small projects:
- SQLiteLight1
A very simple project with a very simple user interface with following functions:
At the first run the database is empty and the user must add entries.
- Add an entry
- Edit an entry
- Update an entry
- Delete an entry
- Display next and previous entry
- SQLiteLight2
A simple project with some more functions:
A default database is supplied to allow the use of the filter without the need to add many entries.
- Display the database in a table with following functions:
-- Add display the Edit activity to add a new entry
-- Edit display the Edit activity to edit an entry
-- Filter filter the database
-- Set Filter display the Filter activity to set the filter
- Edit
-- Add / Update / Delete
-- First / Previous / Next / Last
- Filter
The database is very simple with four columns :
- ID
- FirstName
- LastName
- City
- SQLiteLight3
Same as SQLiteLight2, all functions are the same.
The differences are the database path, database name, table name, columb number, column names, column alias names and column data types are variables instead beeing hard coded.
It allows also to generate a new database by:
- changing in Globals the values of the variables listed above
- in Activity_Create
-- comment this line : 'File.Copy(File.DirAssets, SQLDateBaseName, SQLDataBasePath, SQLDateBaseName)
-- uncomment this line : CreateDataBase
- SQLiteLight4
Multi table example:
The database has three tables and shows the interaction between these tables.
The tables are intentionnaly kept small with only a few columns to keep a clear overview and show how to handle more than one table.
The interface is kept minimalistic and not all possible mistakes are chaecked to keep the code 'short'.
The code has comments and is, I hope, self explanatory.
EDIT: 2014.04.11
Amended error repoted HERE.
EDIT: 2014.05.04
Added SQLiteLight3
Updated SQLiteLight2
EDIT 2015.10.21
SQLiteLight2 and SQLiteLight3 added the Starter Service.
EDIT 2015.11.26
Added SQLiteLight4
Attachments
-
SQLiteLight1.jpg18.6 KB · Views: 6,201
-
SQLiteLight2_1.jpg41.1 KB · Views: 6,005
-
SQLiteLight2_2.jpg20.1 KB · Views: 5,324
-
SQLiteLight2_3.jpg16.4 KB · Views: 5,171
-
SQLiteLight2_4.jpg32.3 KB · Views: 5,559
-
SQLiteLight1.zip130.9 KB · Views: 424
-
SQLiteLight2.zip204.2 KB · Views: 368
-
SQLiteLight3.zip230.8 KB · Views: 358
-
SQLiteLight4.zip229 KB · Views: 389
Last edited: