エラーは、DATABASE_CREATE の設定方法にあると思います。ここで何か不足していますか?long id = -1 の SQLiteException が発生しています。十分な詳細を提供しているかどうかをお知らせください。KEY_ID = "_id"; を設定してみました。
E/SQLiteLog(2385): (1) near "group": syntax error
E/SQLiteDatabase(2385): Error inserting group=demo
E/SQLiteDatabase(2385): android.database.sqlite.SQLiteException: near "group": syntax error (code 1): , while compiling: INSERT INTO groups(group) VALUES (?)
LOG(2385): Inserting record...
LOG(2385): mGroupName = demo
LOG(2385): long id = -1
DBAdapter.java
public static final String KEY_ID = "id";
public static final String KEY_GROUP_NAME = "group";
public static final String TAG = "DBAdapter";
public static final String DATABASE_NAME = "GroupsDB";
public static final String DATABASE_TABLE = "groups";
public static final int DATABASE_VERSION = 1;
private static final String DATABASE_CREATE = "create table if not exists groups (id integer primary key autoincrement, group VARCHAR not null);";
. . .
//---insert a record into the database
public long insertRecord(String group) {
ContentValues initialValues = new ContentValues();
initialValues.put(KEY_GROUP_NAME, group);
return db.insert(DATABASE_TABLE, null, initialValues);
}
MainActivity.java
EditText groupNameText = (EditText) findViewById(R.id.groupNameEditText);
String mGroupname = groupNameText.getText().toString();
...
try {
String destPath = "/data/data/" + getPackageName() + "/databases/GroupsDB";
File f = new File(destPath);
if(!f.exists()) {
CopyDB( getBaseContext().getAssets().open("mydb"),
new FileOutputStream(destPath));
}
}catch (FileNotFoundException e) {
e.printStackTrace();
}catch (IOException e) {
e.printStackTrace();
}
DBAdapter db = new DBAdapter(this);
//try hard coding the record here, if unable to insertRecord for any reason it will return -1
db.open();
long id = db.insertRecord(mGroupname);
Log.i(TAG, "Inserting record...");
Log.i(TAG, "mGroupName = " + mGroupname);
Log.i(TAG, "long id = " + id);
db.close();