I used sqlite
in my previous application to create a database. now I want to create a new application using Room library
. I have a problem where I have more than 100 tables. do I have to declare all my tables in class one by one for all my tables using @Entity
annotation? can I make tables and inserts use rawquery
like what I did in sqlite
such as like this :
@Override public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE TABLE IF NOT EXISTS APP_VERSION( ID INTEGER PRIMARY KEY, LAST_UPDATE TEXT"); }
and can I using rawquery
for insert like this : INSERT INTO table_name VALUES (value1, value2, value3, ...);
do I have to declare all my tables in class one by one for all my tables using @Entity annotation?
Yes.
can I make tables and inserts use rawquerylike what I did in sqlite such as like this :
No. Or, more to the point, Room will only get in the way of you doing this.
because I got the rawquery for create table from webservice
Room is for ordinary Android apps, where you know your table definitions at compile time and can write the Java/Kotlin classes for them (entities, DAOs, RoomDatabase
, @ForeignKey
, etc.).
If you do not know your table definitions at compile time, you will need to work with SQLite directly or find some other library that does not require compile-time knowledge of your database schema.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.