AndoirdプロジェクトのSqliteデータベースに日時フィールドを挿入しようとしています。このように多くの方法を試しましたが、日時フィールドを挿入することはできませんでした。ここに事実があります
1]私のSqliteフィールドはタイプtimestampです
2]データベースクラス
package com.gcm.pushandroid;
import java.util.Date;
public class Notifications {
//private variables
String _type;
String _time_stamp;
// Empty constructor
public Notifications(){
}
// constructor
public Notifications(String type, String timeStamp){
this._type = type;
this._time_stamp = timeStamp;
}
// getting ID
public String getType(){
return this._type;
}
// setting id
public void setType(String type){
this._type = type;
}
// getting timestamp
public String getTimeStamp(){
return this._time_stamp;
}
// setting
public void setTimeStamp(String time_stamp){
this._time_stamp = time_stamp;
}
}
3]ここにコードがあります
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_TYPE, notificationObj.getType());
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
values.put("time_stamp", dateFormat.format(date));
db.insert(TABLE_CONTACTS, null, values);
db.close();
何が悪いのかわからない。ヘルプに感謝します。ありがとうございました