App Crashes On Startup Due To java.lang.IllegalArgumentException: column '_id' does not exist

前端 未结 2 861
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-30 12:11

Whenever I start my app, I get a java.lang.IllegalArgumentException: column \'_id\' does not exist error in my LogCat. I have created the column \'_id\'

2条回答
  •  情歌与酒
    2020-11-30 13:01

    Um not sure if you've just pasted it in wrong but:

     DataHelper = new DataHelper(this);
     Cursor c = (Cursor) DataHelper.selectAll();
    

    is wrong. You need to declare it to an object and call your methods on the initialised DataBase object:

     DataHelper dataHelper = new DataHelper(this);
     Cursor c = (Cursor) dataHelper.selectAll();
    

    Oh my bad you've just declared your variable name with an Uppercase D , this isn't recommended nor standard java coding style.

    http://java.about.com/od/javasyntax/a/nameconventions.htm

提交回复
热议问题