0
我創建了一個數據庫,用於存儲來自互聯網的數據。當有互聯網連接時,我調用createEntry並將數據寫入數據庫。我的問題是,第二次使用互聯網,新的數據並沒有覆蓋舊的,但創建新的條目。所以,我認爲解決方案將更新我的數據庫從第二次,用戶有互聯網連接,所以每次都有相同數量的數據。我的問題是,我不知道該怎麼做。這是我第一次嘗試SQLite和數據庫。如何更新我的數據庫
這是我createEntry:
public void createEntry(String title, String getagonistiki, String getskor,
String getgipedo, String date, String getgoal1, String getgoal2,
String teliko_skor) {
// TODO Auto-generated method stub
ContentValues cv = new ContentValues();
cv.put(DBHelper.TITLE, title);
cv.put(DBHelper.AGONISTIKI, getagonistiki);
cv.put(DBHelper.SKOR, getskor);
cv.put(DBHelper.GIPEDO, getgipedo);
cv.put(DBHelper.DATE, date);
cv.put(DBHelper.GOALA, getgoal1);
cv.put(DBHelper.GOALB, getgoal2);
cv.put(DBHelper.DESCRIPTION, teliko_skor);
try {
ourDatabase.insert("osfpDB", null, cv);
} // ourDatabase.update("osfpDB",cv,DBHelper.ROWID,null);
catch (Exception e) {
Log.e("DB ERROR ON .INSERT", e.toString()); // prints the error
// message to the log
e.printStackTrace(); // prints the stack trace to the log
}
}
,這就是IM通話時,有互聯網連接:
HotOrNot entry = new HotOrNot(agones.this);
entry.open();
entry.createEntry(msg.getTitle(), msg.getagonistiki(), msg
.getskor(), msg.getgipedo(), msg.getDate(),msg.getgoal1(),msg.getgoal2(),msg.getDescription());
// entry.update(msg.getTitle(),msg.getagonistiki(),msg.getskor(),msg.getgipedo(),msg.getDate());
entry.close();