@Override
public void onCreate(SQLiteDatabase db) {
String sql="create table user ( username varchar(20) not null , password varchar(60) not null , regtime DATETIME );";
db.execSQL(sql);
}
DatabaseDemoHelper dbDatabaseDemoHelper = new DatabaseDemoHelper(getApplicationContext());
SQLiteDatabase db = dbDatabaseDemoHelper.getWritableDatabase();
db.execSQL("delete from user", new Object[] {});
ContentValues vls = new ContentValues();
vls.put("username", "zhangsan");
vls.put("password", "123");
vls.put("regtime", new Date().toString());
db.insert("user", null, vls); ContentValues vls2 = new ContentValues();
vls2.put("username", "lisi");
vls2.put("password", "567");
vls2.put("regtime", new Date().toString());
db.insert("user", null, vls2); //new Date().toString() Fri Nov 06 23:58:57 GMT+08:00 2015
//new Date().toLocaleString() 2015年11月7日 上午12:01:42
//new Date().toGMTString() 6 Nov 2015 16:00:02 GMT Cursor cursor = db.rawQuery("select * from user order by regtime desc ", new String[] {});
while (cursor.moveToNext()) {
String userName = cursor.getString(cursor.getColumnIndex("username"));
String password = cursor.getString(cursor.getColumnIndex("password"));
String regtime = cursor.getString(cursor.getColumnIndex("regtime"));
int i = 8;
}