Je suis essayer de mise en œuvre de la Bibliothèque Paging avec salle fourni par Google dans Android architecture Component.But son montrant erreur de compilation de temps dans ma UserDao
classePaging Compile Problème: Je ne sais pas comment convertir un curseur au type de retour de cette méthode
Voici l'erreur:
Error:(22, 42) error: Not sure how to convert a Cursor to this method's return type
Ma question est ce type de retour?
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();
}
Voici le 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());
}
}
je consulter l'exemple suivant:
J'ai soulevé la question HERE
Toute aide serait appréciée