我在MainDao中有一个问题。类:
- 无法解析符号'notes_table'
- 无法解析符号'id'
- 无法解析符号'notes_table'
- 无法解析符号'title'
- 无法解析符号'description'
"我该如何解决这个问题"
我的代码:
第一千一百一十一章等级大道
@Dao
public interface MainDao{
@Insert(onConflict = REPLACE)
void insert(Notes notes);
@Query("SELECT * FROM notes_table ORDER BY id DESC")
List<Notes> getAll();
@Query("Update notes_table SET title = :title, description = :description where id = :id")
void update(int id, String title, String description);
@Delete
void delete(Notes notes);}
RoomDB.java
@Database(entities = Notes.class, version = 1, exportSchema = false)
@Dao
public abstract class RoomDB extends RoomDatabase {
private static RoomDB database;
private static String DATABASE_NAME = "NoteApp";
public synchronized static RoomDB getInstance(Context context) {
if (database == null) {
database = Room.databaseBuilder(context.getApplicationContext(), RoomDB.class, DATABASE_NAME)
.allowMainThreadQueries()
.fallbackToDestructiveMigration()
.build();
}
return database;
}
public abstract MainDao MainDao();
}
Notes.java
@Entity(tableName = "notes_table")
public class Notes implements Serializable {
@PrimaryKey(autoGenerate = true)
int id = 0;
@ColumnInfo(name = "title")
String title = "";
@ColumnInfo(name = "description")
String description = "";
@ColumnInfo(name = "date")
String date = "";
}
1条答案
按热度按时间bxfogqkk1#
您应该在数据库(实体= Notes.class,版本= 1,汇出结构描述= false)变更此项目
至@数据库(实体= {Notes.class},版本= 1,汇出结构描述= false)