查询到 SQLite 数据库出错



>我有一个查询,可以写入我的安卓设备上的SQLite数据库

每次我调用查询时,我都会得到一个空指针异常,

这是我的查询:

Cursor c =  onzedatabase.query(databasetabel, allekolommen, 
                                       waar, null, null, null, null, null);

经过一番研究,我发现onzedatabase = null尽管我根据需要使用所有正确的方法(=>onzedatabase 适用于同一数据库上的所有其他查询(

在我看来,在以下堆栈溢出问题中给出了解决方案:空指针异常错误

但是我如何在我的Android设备上实现此解决方案,我没有任何答案

谢谢你提前帮助我

编辑:

这是我对onzedatabase的初始化

private dbhulp onzehelper;
    private final Context onzecontext;
    private SQLiteDatabase onzedatabase;

    public static class dbhulp extends SQLiteOpenHelper
    {
        public dbhulp(Context context) {
            super(context, ADbAdapter.databasenaam, null, ADbAdapter.databaseversie);
        }
        @Override
        public void onCreate(SQLiteDatabase db) {
        }
        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        }

    }
    public ABezurAdapter(Context c) {
        onzecontext = c;
    }
    public ABezurAdapter open() throws SQLException{
        onzehelper = new dbhulp(onzecontext);
        onzedatabase = onzehelper.getWritableDatabase();
        return this;
    }

onzedatabase null时,很可能以前没有调用过open()

最新更新