2012-12-21 48 views
1

試圖從數據庫中的文本後,我得到這個錯誤:問題從活動傳遞價值的數據源

12-21 09:54:10.948: E/AndroidRuntime(25745): FATAL EXCEPTION: main 
12-21 09:54:10.948: E/AndroidRuntime(25745): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ggservice.democracy/com.ggservice.democracy.sondaggioActivity}: android.database.sqlite.SQLiteException: near "=": syntax error: , while compiling: SELECT _id, preferita, nome FROM sondaggi WHERE _id= 

這是呼叫:

Cursor values = datasource.getDomanda(strcategory); 
     if (values.moveToFirst()) // data? 
       System.out.println(values.getString(values.getColumnIndex("domanda"))); 

       values.close(); 

而它稱之爲:

public Cursor getDomanda(String id) { 
      List<sondaggi> domande = new ArrayList<sondaggi>(); 

      Cursor cursor = database.query(MySQLiteHelper.TABLE_SONDAGGI, 
        allCategorieColumns, MySQLiteHelper.COLUMN_ID + "=", new String[] { id }, null, null, null); 

      cursor.moveToFirst(); 
      while (!cursor.isAfterLast()) { 
       sondaggi sondaggio = cursorToSondaggi(cursor); 
       domande.add(sondaggio); 
       cursor.moveToNext(); 
      } 

      return cursor; 
      } 

id接縫是空的,但我知道那裏有一個值,我已經測試了可變通道。我的意思是,如果我敬酒的strcategory它返回正確的價值。

回答

1

Chnage

Cursor cursor = database.query(MySQLiteHelper.TABLE_SONDAGGI, 
        allCategorieColumns, 
        MySQLiteHelper.COLUMN_ID + "=", 
        new String[] { id }, null, null, null); 

Cursor cursor = database.query(MySQLiteHelper.TABLE_SONDAGGI, 
        allCategorieColumns, 
        MySQLiteHelper.COLUMN_ID + "=?", 
        new String[] { id }, null, null, null); 
+0

哦,問號,非常感謝,我覺得這樣幼稚的,因爲我試圖找出如何在新的lenguage代碼:( –

+0

@peorthyr:ohh!那麼你的長時間整數轉換問題?你解決了嗎 –

+0

我正在處理它,因爲你可以看到我有更多的問題...:D –