我正在使用Room for my android app.我现在正在尝试设置我的数据库,但是有一条错误消息,表示Dao类必须用@Dao注释.但正如你在编码片段中看到的那样,Dao类用@Dao注释.有谁知道问题或我的错误可能在哪里?两个文件都不在同一个文件夹中(DAO在服务文件夹中,而另一个类在模型文件夹中)
Device.java
@Entity(tableName = "device")
public class Device {
@PrimaryKey(autoGenerate = true)
public int device_id;
@ColumnInfo(name = "identifier")
public String identifier;
@ColumnInfo(name = "language")
public int language;
@ColumnInfo(name = "searchFilter")
public int searchFilter;
public Device(String identifier, int language, int searchFilter){
this.identifier = identifier;
this.language = language;
this.searchFilter = searchFilter;
}
}
Run Code Online (Sandbox Code Playgroud)
DeviceDAO.java
@Dao
public interface DeviceDAO {
@Insert(onConflict = OnConflictStrategy.REPLACE)
void addDevicePreferences(DifficultType difficultType);
@Query("SELECT * FROM device")
List<Device> selectAllDevicePreferences();
@Update(onConflict = OnConflictStrategy.REPLACE)
void updateDevicePreferences(Device device);
}
Run Code Online (Sandbox Code Playgroud)