dimanche 10 janvier 2016

How to set a column as autoincrement without making it as Primary key in SQlite

I am trying to make one auto increment column in Sqlite table but i don't want to make it primary key because i have already one column as an primary key in the table.

  private static final String TABLE_GROUP_CREATE
        = "CREATE TABLE " + TABLE_NAME_GROUP
        + " (" + _ID_G + " INTEGER AUTOINCREMENT, "
        + ID_GROUP + " INTEGER PRIMARY KEY NOT NULL, "
        + NAME_GROUP + " VARCHAR(25), "
        + CREATED_GROUP_BY + " VARCHAR(25), "
        + STATUS_GROUP + " VARCHAR(25), "
        + DATE_GROUP + " VARCHAR(25), "
        + MEMBER_GROUP + " VARCHAR(25), "
        +IMG_GROUP + " VARCHAR(25));";

// these variable i am using

private static final String _ID_G = "_idg";
private static final String ID_GROUP = "grp_id";
private static final String TABLE_NAME_GROUP = "covite_group";
public static final String NAME_GROUP = "grp_name";
public static final String CREATED_GROUP_BY = "grp_created_by";
private static final String STATUS_GROUP = "grp_status";
private static final String DATE_GROUP = "grp_date";
private static final String MEMBER_GROUP = "grp_member";
private static final String IMG_GROUP = "grp_img";

when with the same code when i make the field _ID_G as a primary key then its work when i remove it the primary key the its generate the Exception.

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire