Java SQLite插入NullException?

Java SQLite插入NullException?,java,android,sql,database,nullpointerexception,Java,Android,Sql,Database,Nullpointerexception,出于某种原因,我的代码在尝试插入表时返回NullException?我非常困惑 try{ if(contactsh.selectAll().size() > 0){ for(int i = 0; i < contactsh.selectAll().size() - 1; i++){ names[i] = contactsh.selectAll().get(i); } } e

出于某种原因,我的代码在尝试插入表时返回NullException?我非常困惑

try{
        if(contactsh.selectAll().size() > 0){
            for(int i = 0; i < contactsh.selectAll().size() - 1; i++){
                names[i] = contactsh.selectAll().get(i);
            }
        } else {

        }
    } catch(Exception e){
        contactsh.insert("Example"); //ERROR IS HERE
        timeh.insert("20:20");
        dateh.insert("06/27/27");
        txth.insert("1-555-555-5555");
        Log.w("initiate contacts error: ", e.toString());
    }
下面是我在类中为DatabaseHelper插入的方法:

public long insert(String name){
    this.insertStmt.bindString(1, name);
    return this.insertStmt.executeInsert();
}

如果您需要查看我的整个课程,我将非常乐意在这里发布。

可能需要查看更多代码,但我希望
这个。insertStmt
为null或者
contactsh
为null。

需要进一步了解您的帮助者课程以帮助您。让我们看看你在
insertStmt
中使用了什么,它是
executeInsert()
方法。哇,我想你是对的。大脑放屁。。。我没有定义contactsh(新ContactDatabase())。谢谢,我想它起作用了。
public long insert(String name){
    this.insertStmt.bindString(1, name);
    return this.insertStmt.executeInsert();
}