我使用下面的SQL语句sqlite的时间戳
private static final String DATABASE_CREATE = "create table "+ TABLE_USERLOCATION + "("
+ COLUMN_ID+" integer primary key autoincrement, "
+ COLUMN_LONGITUDE +" real not null, "
+ COLUMN_LATITUDE+" real not null, "
+ COLUMN_TIME + " timestamp not null default current_timestamp);";
创建数据库时,我尝试通过
cursor.getColumnIndex(GPSSqliteHelper.COLUMN_TIME)
得到COLUMN_TIME我得-1(如此明显的错误)
但当我进入我的模拟器中的数据库目录并查看所有条目时,我看到已添加时间戳:
1 | 2.71828 | 3.14159166666667 | 2013年4月9日0时05分50秒
2 | 2.71828 | 3.14159166666667 | 2013年4月9日0时35分09秒
如何访问的日期和原因getColumnCount()返回3而不是4?
我通过this教程(我的表创建语句基本上类似于那里提供的那个)。
欢呼声
你是什么'SELECT'语句或'query()'? – Sam 2013-04-09 16:25:47
确保您的'COLUMN_TIME'中没有前导空格,即'public static final String COLUMN_TIME =“time”;' – jnthnjns 2013-04-09 16:41:17
该光标的查询是什么? – 2013-04-09 17:06:07