Hi all, currently I'm working on my 1st Android app and I encounter something I cannot solve. When I try to insert data into my own database there is an error: 07-18 03:41:04.414: ERROR/AndroidRuntime(3480): java.lang.NullPointerException
My code for inserting into table is:
public long createRecord(String created_time, String modified_time,
long reading, String unit, String period, String remark) {
ContentValues values = new ContentValues(6);
values.put(KEY_CREATED_TIME, created_time);
values.put(KEY_MODIFIED_TIME, modified_time); //System.out.println(values);
values.put(KEY_RECORD, reading); //System.out.println(values);
values.put(KEY_UNIT, unit); //System.out.println(values);
values.put(KEY_PERIOD, period);// System.out.println(values);
values.put(KEY_REMARK, remark);
System.out.println(values);
return mDb.insert(DATABASE_TABLE, null , values);
}
This is under my Adapter class which is an instance of my DatabaseHelper class. For my DatabaseHelper class, I can copy created database from assets folder into system databases folder. But just cannot create data into table, I tried to print out the "values", it showed that:
created_time=2010-07-18 03:41:04 remark=on unit=mg/dL reading=67 period=Before Meal modified_time=00:00:00 which was not the way it supposed to be, so I guessed this might be the problem. Can anyone help me with this? Searched online but not so many info on this. Thanks in advance:)