boolean DBExist = checkDatabaseExist();
Toast.makeText(this,DBExist + " <- DB Exists :p",Toast.LENGTH_LONG).show();
if(!DBExist){
SQLiteDatabase DB = openOrCreateDatabase(DB_NAME, MODE_PRIVATE, null);
try{
DB.execSQL("CREATE TABLE IF NOT EXISTS SubjectsDB(name VARCHAR, major VARCHAR);");
DB.execSQL("INSERT INTO SubjectsDB(\'softskill\',\'no\');");
}catch (Exception e){
Toast.makeText(this,"Ohh!!"+e.toString(),Toast.LENGTH_LONG).show();
}
Toast.makeText(this,"Data Entered Successfully",Toast.LENGTH_LONG).show();
这是我试图将两个字符串插入数据库的代码,但它以分号显示错误
答案 0 :(得分:0)
使用以下代码
DB.execSQL("INSERT INTO SubjectsDB values(\'softskill\',\'no\');");