I\'m trying to create the following database:
public static final String KEY_NAME = \"nombre\";
public static final String KEY_ROWID = \"_id\";
public static fin
I haven't worked with Android, so this could be off, but it appears you're sending the ID with the insert into CAPAS table, but it's unnececessary because you have it defined as AUTOINCREMENT.
You have:
public long createCapa(String id, String nombre) {
ContentValues initialValues = new ContentValues();
initialValues.put(KEY_ID, id);
initialValues.put(KEY_NAME, nombre);
return mDb.insert(DATABASE_TABLE_CAPAS, null, initialValues);
}
What happens if you do this?
public long createCapa( String nombre) {
ContentValues initialValues = new ContentValues();
//initialValues.put(KEY_ID, id);
initialValues.put(KEY_NAME, nombre);
return mDb.insert(DATABASE_TABLE_CAPAS, null, initialValues);
}
and this:
createCapa("Escuelas");
Is it really common practice to define both _id and id in Android? When you define the pk as integer primary key in SQLite it becomes an alias for the rowid automatically. Here's how I would do it normally:
create table capas (id integer primary key autoincrement, nombre text not null);