Insert JSON data into the SQLite database in android

给你一囗甜甜゛ 提交于 2019-11-30 04:00:49

you forget to initialize databaseHelper object in oncreate of Activity before using it.

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        databaseHelper=new CategoryHelper(AndroidJSONParsingActivity.this);
        //your code here..........

You never instantiate databaseHelper. You can't call a method on a null object.

And you have one more little problem here:

db.execSQL("DROP TABLE IF EXISTS"+ TABLE_NAME);

You have forgotten space character after EXISTS. It should looks like this:

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