Предварительное заполнение данных в базе данных номеров — AndroidAndroid

Форум для тех, кто программирует под Android
Гость
Предварительное заполнение данных в базе данных номеров — Android

Сообщение Гость »


I have a room database configuration like below.

Код: Выделить всё

Room.databaseBuilder(context.applicationContext, AppDataBase::class.java, "wallet.db"       ).setQueryCallback(QueryInterceptor(), executor = Executors.newSingleThreadScheduledExecutor()         ).createFromAsset("attributes.db").build()

I want to add some default pre-populated categories into an attributes table. Because user can also add or edit the present pre-populated data.

attributes.db has below queries.

Код: Выделить всё

CREATE TABLE IF NOT EXISTS 
attributesid

Код: Выделить всё

INTEGER PRIMARY KEY AUTOINCREMENT,
key

Код: Выделить всё

TEXT NOT NULL,
value

Код: Выделить всё

TEXT NOT NULL,
meta_data

Код: Выделить всё

TEXT DEFAULT '',
isActive

Код: Выделить всё

 INTEGER NOT NULL, PRIMARY KEY(
id`) );

INSERT INTO

Код: Выделить всё

attributes_in_detail
(, ,

Код: Выделить всё

isActive
) VALUES (

Код: Выделить всё

essentials
,

Код: Выделить всё

Rent/mortgage
, 1); ` I am not able to see the attributes.db queries getting run. Please help me how can I archive this in android room database.


Источник: https://stackoverflow.com/questions/781 ... se-android

Вернуться в «Android»