通过ContentValues​​插入时间戳到SQLite的

编程入门 行业动态 更新时间:2024-10-11 13:19:43
本文介绍了通过ContentValues​​插入时间戳到SQLite的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在Android的:是有可能使用插入时间戳到SQLite数据库 ContentValues​​

In Android: is it possible to insert a timestamp into a SQLite database using ContentValues?

当我尝试添加它使用类似

When I try to add it using something like

ContentValues args = new ContentValues(); args.put(MY_DATE, my_date);

我得到一个错误,告诉我​​, my_date 必须是一个字符串

推荐答案

无论是日期和日历是有效的事情把在ContentValues.最有效的形式,我觉得,是对日期转换为毫秒(的getTime()),并存储在一个 INTEGER 列。

Neither Date nor Calendar are valid things to put in a ContentValues. The most efficient format, I think, is to convert the Date to milliseconds (getTime()) and store that in an INTEGER column.

更多推荐

通过ContentValues​​插入时间戳到SQLite的

本文发布于:2023-10-26 17:50:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1530896.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时间   ContentValues   SQLite

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!