在真机上测试时一点“添加备忘录”这个按钮就闪退,
想知道是什么原因,应该怎样解决。
求大神不吝赐教,感谢!!
贴一下创建数据库的代码的代码:
NotesDB.java
package com.example.datenote; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class NotesDB extends SQLiteOpenHelper { public static final String TABLE_NAME_NOTES = "note"; public static final String COLUMN_NAME_ID = "_id"; public static final String COLUMN_NAME_NOTE_CONTENT = "content"; public static final String COLUMN_NAME_NOTE_DATE = "date"; public NotesDB(Context context) { super(context, "note", null, 1); // TODO Auto-generated constructor stub } @Override public void onCreate(SQLiteDatabase db) { String sql = "CREATE TABLE " + TABLE_NAME_NOTES + "(" + COLUMN_NAME_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + COLUMN_NAME_NOTE_CONTENT + " TEXT NOT NULL DEFAULT\"\"," + COLUMN_NAME_NOTE_DATE + " TEXT NOT NULL DEFAULT\"\"" + ")"; Log.d("SQL", sql); db.execSQL(sql); // String sql1="insert into "+TABLE_NAME_NOTES+"values("+"1,"+"'写作业',"+"'晚上要写作业的干活'"+")"; // Log.d("SQL1", sql1); // db.execSQL(sql1); // ContentValues values=new ContentValues(); // values.put("id",1); // values.put("content","写作业"); // values.put("date", "2013-1-2"); // db.insert("note", null, values); } @Override public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) { // TODO Auto-generated method stub } }
慕设计2395807
绝尘释爱