@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;
}

android sqlite datetime demo的更多相关文章

  1. Android SQLite总结(一) (转)

    Android SQLite总结(一)  郑海波 2012-08-21 转载请声明:http://blog.csdn.net/nuptboyzhb/article/details/7891887 前言 ...

  2. Android Sqlite 导入CSV文件 .

    http://blog.csdn.net/johnnycode/article/details/7413111 今天遇到 Oracle 导出的12万条CSV格式数据导入 Android Sqlite ...

  3. Android SQLite总结[转载]

    [转载] :http://blog.163.com/zqy216_2008/blog/static/4119371820119954812509/ 最近在做的项目涉及到了SQLite,大学时没有好好学 ...

  4. TensorFlow 在android上的Demo(1)

    转载时请注明出处: 修雨轩陈 系统环境说明: ------------------------------------ 操作系统 : ubunt 14.03 _ x86_64 操作系统 内存: 8GB ...

  5. Android SQLite 通配符查询找不到参数问题

    使用Android SQLite中SQLiteDatabase类的query方法查询时,如果where中包含通配符,则参数会无法设置,如类似下面的方法查询时 SQLiteDatabase db = d ...

  6. Android+Sqlite 实现古诗阅读应用(三)

    往期传送门: Android+Sqlite 实现古诗阅读应用(一) Android+Sqlite 实现古诗阅读应用(二) 加入截图分享的功能. 很多应用都有分享的功能,我也想在我的古诗App里加入这个 ...

  7. Android+Sqlite 实现古诗阅读应用(二)

    传送门:Android+Sqlite 实现古诗阅读应用(一) Hi,又回来了,最近接到很多热情洋溢的小伙伴们的来信,吼开心哈,我会继续努力的=-=! 上回的东西我们做到了有个textview能随机选择 ...

  8. Android Sqlite 数据库版本更新

      Android Sqlite 数据库版本更新 http://87426628.blog.163.com/blog/static/6069361820131069485844/ 1.自己写一个类继承 ...

  9. android SQLite使用SQLiteOpenHelper类对数据库进行操作

    android SQLite使用SQLiteOpenHelper类对数据库进行操作 原文: http://byandby.iteye.com/blog/835580

随机推荐

  1. 64位Windows2008下插入Oracle中文乱码问题解决

    最近迁移一个.net应用系统从32位Windows2003升级到64位的Windows2008中,发现所有涉及中文的内容插入到Oracle数据库中都变为?,最开始以为是2008系统的字符集与Oracl ...

  2. Spark读取Hbase的数据

    val conf = HBaseConfiguration.create() conf.addResource(new Path("/opt/cloudera/parcels/CDH-5.4 ...

  3. 让一个端口同时做两件事:http/https和ssh

    相信很多人都在YY:能不能让80端口分析连接协议,如果是http协议就让服务器交给http服务程序(如Apache.Nginx等)处理,如果是ssh协议就交给ssh服务程序(如OpenSSH Serv ...

  4. 对话框AlertDialog.Builder使用方法

    我们在平时做开发的时候,免不了会用到各种各样的对话框,相信有过其他平台开发经验的朋友都会知道,大部分的平台都只提供了几个最简单的实现,如果我们想实现自己特定需求的对话框,大家可能首先会想到,通过继承等 ...

  5. 关于32位windows与4GB内存的那些事儿

    参考:1 Physical Address Extensionzh.wikipedia.org/wiki/PAEen.wikipedia.org/wiki/Physical_Address_Exten ...

  6. <2016-1-28>

    1.链接的网址前加入?action=bs-transfer@mdp&url=http://www.baidu.com 2.登录页面的验证 <script> function log ...

  7. Python socket超时

    #server.py import socket s=socket.socket() s.bind(('127.0.0.1',2000)) s.listen(5) while 1: cs,addres ...

  8. java @Autowired与@Resource的区别

    @Autowired与@Resource的区别     1.@Autowired与@Resource都可以用来装配bean. 都可以写在字段上,或写在setter方法上. 2.@Autowired默认 ...

  9. 【VB6】使用VB6创建和访问Dom树【爬虫基础知识 】

    使用VB6创建和访问Dom树 关键字:VB,DOM,HTML,爬虫,IHTMLDocument 我们知道,在VB中一般大家会用WebBrowser来获取和操作dom对象. 但是,有这样一种情形,却让我 ...

  10. .gitignore 使用中注意的问题

    在git中如果想忽略掉某个文件,不让这个文件提交到版本库中,可以使用修改 .gitignore 文件的方法.这个文件每一行保存了一个匹配的规则例如: # 此为注释 – 将被 Git 忽略 *.a    ...