Summary
Keywords
Full Transcript
Learning outcomes ----------------------------------- 1) How to create a table and database private static final String DATABASE_NAME = "student.db"; private static final String TABLE_NAME = "student_details"; private static final String ID = "_id"; private static final String NAME = "Name"; private static final String AGE = "Age"; private static final int DATABASE_VERSION_NO = 1; private static final String CREATE_TABLE = "CREATE TABLE "+TABLE_NAME+"("+ID+" INTEGER PRIMARY KEY AUTOINCREMENT,"+NAME+" VARCHAR(255),"+AGE+" INTEGER);"; private Context context; public MyDataBaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION_NO); this.context = context; } @Override public void onCreate(SQLiteDatabase db) { try { Toast.makeText(context,"onCreate is called",Toast.LENGTH_SHORT).show(); db.execSQL(CREATE_TABLE); }catch (Exception e) { Toast.makeText(context,"Exception : "+e,Toast.LENGTH_SHORT).show(); } } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { } sql Database : https://www.youtube.com/playlist?list=PLgH5QX0i9K3qLcx9DvVDWmNJ7riPvxzCD Subscribe : https://www.youtube.com/channel/UCEXwc6mNh7Lakj6lX-7a2Mg Facebook : https://www.facebook.com/anisul2010s Facebook page : https://www.facebook.com/studywithanis/
