2010-09-24 111 views
1

大家好 我創造這樣的在SQLite的查詢沒有結果

private static final String CREATE_TABLE_PRODUCT = 
"create table prod (id integer primary key,titre text not null, desc text, is_free integer);"; 

表我這樣

SQLiteDatabase db = getConnection(); 
    ContentValues updateEvent = new ContentValues(); 
    updateEvent.put("is_free", 1); 

    int ok = db.update(prod, updateEvent, "id=?", 
      new String[] { Long.toString(evenement.getId()) }); 

    db.close(); 
更新

我確實看到日食與DDMS questoid

變化但是當我嘗試檢索的價值,我得到什麼....

 Cursor c = db.query(prod, new String[] { "id", 
       "titre", "desc", "is_free", }, 
       "is_free=?", new String[] {"1"}, null, null, 
       null); 

我已經試過像

String query = "SELECT * FROM "+EVENEMENT_TABLE+" WHERE is_free=1;"; 
    Cursor c = sdb.rawQuery(query, null); 

沒有成功

一些變體從我列的類型(整數)來這個問題呢? 任何幫助

+0

這種方式工作光標c = db.query(prod,new String [] {「id」, 「titre」,「desc」,「is_free」,}, 「is_free = 1」,,null,null , null); – superseed77 2010-09-24 13:25:20

回答

0

不要在您的查詢中使用保留關鍵字desc。這可能會導致查詢失敗。 如果您不知道update將不會將值添加到表中。改爲使用insert