Androidでデータベースを作成しようとしていますが、実行すると例外が発生します:
Database - Failure 1 (near "integer" : syntax error) on 0x1ac028 when preparing 'create table list1 (id integer Primary key autoincrement, task text not null, check integer not null)'
なぜこれが起こっているのかわかりません。これは私のコードです:
String dbName="projectDatabase";
String tableName="List1";
String TableStructure="create table " + tableName +" (id integer Primary key autoincrement, task text not null, check integer not null)";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button cb = (Button) findViewById(R.id.creatbutton);
cb.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
try{
SQLiteDatabase ldb = openOrCreateDatabase(dbName, Context.MODE_PRIVATE, null);
ldb.execSQL(TableStructure);}catch(Exception e){
Toast.makeText(DsTest2Activity.this, "Failed", Toast.LENGTH_LONG).show();
}
Intent list = new Intent(DsTest2Activity.this,List.class);
startActivity(list);
}
});
}