0
我一直试图实现的寻呼图书馆与谷歌在Android中架构提供客房Component.But其显示编译时错误在我UserDao
类寻呼编译问题:不知道如何将光标转换成该方法的返回类型
这里是错误:
Error:(22, 42) error: Not sure how to convert a Cursor to this method's return type
我的问题是什么返回类型?
UserDao.java
@Dao
public interface UserDao {
@Query("SELECT * FROM user")
LiveData<List<User>> getAll();
//Compile Error is here : Not sure how to convert a Cursor to this method's return type
@Query("SELECT * FROM user")
LivePagedListProvider<Integer, User> userByPagination();
}
这里UserModel.java
public class UserModel extends AndroidViewModel {
private final UserDao userDao;
public UserModel(Application application) {
super(application);
userDao = RoomDB.getDefaultInstance().userDao();
}
public LiveData<List<User>> getAllUser() {
return userDao.getAll();
}
public LiveData<PagedList<User>> getAllUserPagination() {
return userDao.userByPagination().create(
/* initial load position */ 0,
new PagedList.Config.Builder()
.setEnablePlaceholders(true)
.setPageSize(10)
.setPrefetchDistance(5)
.build());
}
}
我有参考下面的示例:
我提出HERE
任何帮助,将不胜感激