app/src/main/java/com/example/android/pets/data/PetDbHelper.java
/**
     * this is called when the database is created for the first time.
     */
this is called when the database is created for the first time.
this is called when the database is created for the first time .
@Override
    public void onCreate(SQLiteDatabase db) {
        String SQL_CREATE_PETS_TABLE = "CREATE TABLE " + PetContract.PetEntry.TABLE_NAME + " ("
                + PetContract.PetEntry._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
                + PetContract.PetEntry.COLUMN_PET_NAME + " TEXT NOT NULL, "
                + PetContract.PetEntry.COLUMN_PET_BREED + " TEXT, "
                + PetContract.PetEntry.COLUMN_PET_GENDER + " INTEGER NOT NULL, "
                + PetContract.PetEntry.COLUMN_PET_WEIGHT + " INTEGER NOT NULL DEFAULT 0);";
        db.execSQL(SQL_CREATE_PETS_TABLE);
    }
@ Override public void onCreate ( SQLiteDatabase db ) { String SQL_CREATE_PETS_TABLE = "CREATE TABLE " + PetContract . PetEntry . TABLE_NAME + " (" + PetContract . PetEntry . _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + PetContract . PetEntry . COLUMN_PET_NAME + " TEXT NOT NULL, " + PetContract . PetEntry . COLUMN_PET_BREED + " TEXT, " + PetContract . PetEntry . COLUMN_PET_GENDER + " INTEGER NOT NULL, " + PetContract . PetEntry . COLUMN_PET_WEIGHT + " INTEGER NOT NULL DEFAULT 0);" ; db . execSQL ( SQL_CREATE_PETS_TABLE ) ; }
this is called when the database is created for the first time.
this is called when the database is created for the first time .
// create a String that contains SQL statement to create the pets table // execute the SQL statement