Adding image to android SQLite Database

我们两清 提交于 2019-12-02 09:14:18

change from this:

private ContentValues createContentValues(byte[] Image) {
    ContentValues values = new ContentValues();
    values.put(KEY_IMAGE, Image);

    return values;
}

public long addImage(byte[] image){
ContentValues cv = createContentValues(image);
return mDb.insert(DATABASE_TABLE, null, cv);
}

It's likely that your mDb database variable has not been initialized correctly, viz your database provider is null. I normally separate the Helper and DataProvider classes rather than merge them into one class as you have done.

I would recommend you follow the same methodology as show in Lars Vogel's excellent SQLite tutorial.

Hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!