小编Mar*_*222的帖子

How to pre-populate Room database at first run?

I am creating an android app in java that uses room SQLite to store data. The app have two tables:

  • CoursesTable
  • StudentsTable

I want to add default values for course_name entity so when the user open the app find the courses.

For example :

Math - Sport - Art - Music

@Entity
public class CoursesTable {
   @PrimaryKey(autoGenerate = true)
   int course_id;
   String course_name;
}
Run Code Online (Sandbox Code Playgroud)

sql android android-room

1
推荐指数
1
解决办法
351
查看次数

标签 统计

android ×1

android-room ×1

sql ×1