简体   繁体   English

查询到sqlite数据库出错了

[英]query to sqlite database going wrong

i have a query that writes to the sqlitedatabase on my android device 我有一个查询写入我的Android设备上的sqlitedatabase

everytime I call the query i get an nullpointerexception, 每当我调用查询时,我都会得到一个nullpointerexception,

here my query: 在这里我的查询:

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

after some research i found out that onzedatabase = null although i use all the correct methods as needed (=>onzedatabase works for all the other queries on the same database) 经过一些研究后我发现onzedatabase = null虽然我根据需要使用了所有正确的方法(=> onzedatabase适用于同一数据库上的所有其他查询)

in my opinion a solution is given in the following stackoverflow question: nullpointerexception fault 在我看来,在下面的stackoverflow问题中给出了一个解决方案: nullpointerexception fault

but how do i implement this solution on my android device, i don't uderstand anything of the answer 但我如何在我的Android设备上实现此解决方案,我不理解任何答案

thanks for helping me in advance 谢谢你提前帮助我

edit: 编辑:

here my initialazing of onzedatabase 这里是我对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;
    }

onzedatabasenull ,很可能之前没有调用open()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM