在真機(jī)上測試時一點(diǎn)“添加備忘錄”這個按鈕就閃退,想知道是什么原因,應(yīng)該怎樣解決。求大神不吝賜教,感謝!!貼一下創(chuàng)建數(shù)據(jù)庫的代碼的代碼:NotesDB.javapackage?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,"+"'寫作業(yè)',"+"'晚上要寫作業(yè)的干活'"+")";??
//??????Log.d("SQL1",?sql1);??
//??????db.execSQL(sql1);??
//??????ContentValues?values=new?ContentValues();??
//??????values.put("id",1);??
//??????values.put("content","寫作業(yè)");??
//??????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??
??
????}??
??
}
添加回答
舉報
0/150
提交
取消