lundi 14 septembre 2015

Display current date

below are some part of my javascript in my database, how do i add an auto current date if i save my data? the _DATE and _TIME i used is using textfields, but i wanted to use display current date when i save the diary

private static final String DIARY_TABLE = "diarytable";
        private static final String _ID = "id";
        private static final String _NAME = "workout";
        private static final String _DATE = "date";
        private static final String _TIME = "time";
        private static final String _NOTES = "notes";

public data(Context context) {
            super(context, DB_NAME, null, DB_VERSION);
            this.context=context;
        }



        @Override
        public void onCreate(SQLiteDatabase db) {
            try{
               // db.execSQL(CREATE_TABLE);
                db.execSQL("CREATE TABLE " + TABLE_NAME + " ( " + UID + " integer primary key autoincrement," +
                        "" + NAME + " VARCHAR(50), " +
                        "" + _STATUS + " VARCHAR(255)," +
                        "" + WEIGHT + " VARCHAR(255));");
                message.mess(context,"Database Created");

 //               db.execSQL(CREATE_TABLE1);
                db.execSQL("CREATE TABLE "+ DIARY_TABLE+ " ( "+_ID+" integer primary key autoincrement," +
                        ""+_NAME+" VARCHAR(50), " +
                        ""+_DATE+" VARCHAR(10)," +
                        ""+_TIME+" VARCHAR(5)," +
                        ""+_NOTES+" VARCHAR(255));");
                message.mess(context,"Second Database Created");

            }
            catch(SQLException e){
                message.mess(context, "Failed" +e);
            }
        }

Aucun commentaire:

Enregistrer un commentaire