开发者

Store Time in database

i am new to android, i want to store the time and retrieve the time in sq lite database. Any 开发者_StackOverflow中文版one help me to solve the problem.


Knowing that you will never accept an answer but willing to still help:

Create a column, date as Integer, and store the time as a number (in milliseconds). That is how all of the tutorials and example apps do it.

http://developer.android.com/resources/samples/NotePad/src/com/example/android/notepad/NotePadProvider.html

Example:

   @Override
   public void onCreate(SQLiteDatabase db) {
       db.execSQL("CREATE TABLE " + NotePad.Notes.TABLE_NAME + " ("
               + NotePad.Notes._ID + " INTEGER PRIMARY KEY,"
               + NotePad.Notes.COLUMN_NAME_TITLE + " TEXT,"
               + NotePad.Notes.COLUMN_NAME_NOTE + " TEXT,"
               + NotePad.Notes.COLUMN_NAME_CREATE_DATE + " INTEGER," // <- see
               + NotePad.Notes.COLUMN_NAME_MODIFICATION_DATE + " INTEGER"
               + ");");
   }


There is a nice tutorial on Android dev documentation , Data Storage, that show how to use it


look into sqlite documentation http://www.sqlite.org/datatype3.html#datetime

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜