There Is No Preview Available For This Item. This item does not appear to have any files that can be experienced on Archive.org.
Aug 23, 2019
There Is No Preview Available For This Item. This item does not appear to have any files that can be experienced on Archive.org.
Q:
Persistent data in SQLite Android
I need to make a simple app.
I need to create a database, which will be filled with the data.
It is required that after closing the application, the data from the database will be loaded into the same database.
Also I will need to update the database when the new data is sent to me.
Can somebody tell me what kind of database to choose?
A:
You have many options to store data in sqlite.
You can either use single table (one table) or multiple tables. You can also store data in sqlite in one of two ways, static or dynamic.
Single Table
If your data doesn't change frequently, one is better than the other. You can create a table as :
CREATE TABLE IF NOT EXISTS "TEST" (
"ID" INTEGER PRIMARY KEY AUTOINCREMENT,
"TEXT" VARCHAR(20)
);
Or you can create multiple tables in a single database if you are going to get data.
Multiple Tables
If your data changes frequently or you want to add more columns, you can create multiple tables in a database :
CREATE TABLE IF NOT EXISTS "TEST" (
"ID" INTEGER PRIMARY KEY AUTOINCREMENT,
"TEXT" VARCHAR(20),
"OTHER" VARCHAR(20),
);
Here you can use a query like :
SELECT * FROM "TEST"
or you can add more columns to the table and query like :
SELECT * FROM "TEST" WHERE "TEXT" = 'Something';
Static
This data will always stay and you can update the tables as many time as you want.
Dynamic
If your data change frequently and you have no idea about the new data. Then you can create a database in the following way :
public class DataBaseHelper extends SQLiteOpenHelper {
public static final String DATABASE_NAME = "mydatabase.db be359ba680
Related links:
Comments