[英]SugarORM: SugarRecord.count returns 4 but SugarRecord.listAll returns empty list
我使用@Table
注釋為我的模型和呼叫SugarRecord.save
在DialogFragment.setPositiveButton.onClick
在帶有 ListView 的片段中,我想通過SugarRecord.listAll
加載所有條目,但它返回一個空列表,盡管SugarRecord.count
返回正確的計數。
@Table
@ToString
@Getter
public class Syllable {
private Long id;
@Unique
String characters;
@Setter
boolean active = true;
public Syllable(String characters) {
this.characters = characters;
}
}
.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
SugarRecord.save(new Syllable(charactersET.getText().toString()));
syllableDialogListener.onSyllableSave();
}
})
private void updateSyllables() {
long count = SugarRecord.count(Syllable.class); // returns 4 (e.g.)
List<Syllable> syllables = SugarRecord.listAll(Syllable.class); // returns empty list
}
好的,我只是在模型中缺少一個空的構造函數 >>> 問題是這在 android studio 中並沒有真正打印為紅色錯誤樣式的錯誤,所以我只是錯過了這個;D
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.