0

I'm working with database, and I the following data class

datahelper.java

private static final String CREATE_TABLE = "create table "
        + TABLE_MEMBER + "(" + MEMBER_ID
        + " INTEGER PRIMARY KEY AUTOINCREMENT, "
        + MEMBER_NAME + " TEXT NOT NULL,"
        + MEMBER_DATE + " TEXT NOT NULL);";

and it point the error code to this two java file

SQLController.java

 public Cursor readData() {
        String[] allColumns = new String[] { DBhelper.MEMBER_ID,DBhelper.MEMBER_NAME,DBhelper.MEMBER_DATE};
        Cursor c = database.query(DBhelper.TABLE_MEMBER, allColumns,null, null, null, null, null);
        if (c != null) {
        c.moveToFirst();
       }
        return c;
    }

Mainactivity.java

     protected void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);


  setContentView(R.layout.activity_main);
        dbcon = new SQLController(this);
        dbcon.open();
        addmem_bt = (Button) findViewById(R.id.addmem_bt_id);
        lv = (ListView) findViewById(R.id.memberList_id);

        addmem_bt.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent add_mem = new Intent(MainActivity.this, Add_member.class);
                startActivity(add_mem);
            }
        });

        // Attach The Data From DataBase Into ListView Using Crusor Adapter
        Cursor cursor = dbcon.readData();
        String[] from = new String[] { DBhelper.MEMBER_ID, DBhelper.MEMBER_NAME, DBhelper.MEMBER_DATE };
        int[] to = new int[] { R.id.member_id, R.id.member_name, R.id.member_date};

thx all your help

Adrian Cid Almaguer
  • 7,815
  • 13
  • 41
  • 63
Wei Chi
  • 29
  • 1
  • 8

1 Answers1

1

date is a function in sqlite, I suspect you cant use as column name or alias

Simone Sanfratello
  • 1,520
  • 1
  • 10
  • 21
  • That shouldn't matter. There's a list of keywords at https://www.sqlite.org/lang_keywords.html that you have to escape if you want to use them as a column name, but `date` isn't on it. – Dawood ibn Kareem Mar 15 '15 at 06:44
  • because is a function, not a reserved word https://www.sqlite.org/lang_datefunc.html – Simone Sanfratello Mar 15 '15 at 07:10
  • i have rename the date to "event" and its work, but i compile the apps the error still appear the apps can still can run. now i facing another problem, when i modify the data i jst added in, my member name colum data succesful changed, bt the new data of the event column data move to member name column and combine together. The event column is still remain the old data. example: member name column : abc ; event column : 123. I modify to cde and 456, after click modify button then become member name colum:cde456,event:123 . sry for my bad explanation – Wei Chi Mar 15 '15 at 08:21