Android:在RecyclerView Adapter中,如何测试SQLite数据库中的条目是否为Null



我有一个 RecyclerView 的 CardView 列表。 卡片视图显示存储在 SQLite 数据库中的用户输入的数据。 数据库中的数据字段之一是 DueDate thtat 存储来自 DatePicker 的日期。 如果用户未输入 DueDate,则 DueDate 列的 SQLite 数据库条目为"NULL"。

我想在 onBindViewHolder() 中测试到期日期条目是否为"NULL"。 我在这里错过了什么?

模型文件为联系人.java:

private String duedate;
...
public String getDuedate() {
    return duedate;
}

回收器视图适配器.java:

...
private List<Contact> contactList;
public ContactListAdapter(Context context) {
    this.context = context;
    this.contactList = new ArrayList<>();
}
...
public void onBindViewHolder(final RecyclerView.ViewHolder viewHolder, int position) {
    final Contact contact = contactList.get(viewHolder.getAdapterPosition());
    final ContactHolder holder = (ContactHolder) viewHolder; 
    *** here is where I'm lost ***
    if (contact.getDuedate() = isNull) { // If no DueDate, setText below.
        holder.cardBlankText10.setText("DueDate not entered");
    } else {    
    ...
*** here is where I'm lost ***
    if (contact.getDuedate() == null) { // If no DueDate, setText below.
        holder.cardBlankText10.setText("DueDate not entered");
    } else {   

最新更新