2012-10-27 13 views
5

Viene visualizzato questo errore su un dispositivo, mentre funziona correttamente su un altro dispositivo. Ecco l'errore:Android: SQLiteException: non un errore non su tutti i dispositivi

Caused by: android.database.sqlite.SQLiteException: not an error 
    at android.database.sqlite.SQLiteQuery.nativeFillWindow(Native Method) 
    at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:86) 
    at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:164) 
    at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:156) 
    at com.Orange.MakeVisits.Themes.onCreate(Themes.java:162) 

eseguo una query e alla linea che controlla se il cursore è nullo, ottengo questo errore. Ecco il mio codice:

String stmtGetThemes = "SELECT * FROM pr_fields_descriptor a " 
    + "inner join pr_fields_starring b on a.id_fields_descriptor = b.fields_descriptor_id " 
    + "where b.starring_id = '"+pos_starring_id+"' and a.theme_id='"+themes_ids[m]+"' order by form_rank"; 

    Cursor getThemesCursor1 = db.databaseQuery(stmtGetThemes); 

    if (getThemesCursor1!=null && getThemesCursor1.getCount()>0){ 
    //---- 
    } 

e databasequery è questo metodo (è definito nella classe che si estende SQLiteOpenHelper):

public Cursor databaseQuery(String stmt) { 
     Cursor cursor = db.rawQuery(stmt, null); 
     return cursor; 
    } 

Qualche idea di cosa può causare questo errore? La dichiarazione non è buona? Perché funziona su altri dispositivi? Qualsiasi idea è ben accetta. Grazie in anticipo.

+0

Se 'pos_starring_id' e' themes_ids [m] 'sono numeri interi, è necessario rimuovere i virgolette (' '') attorno ad essi dalla query in modo che non vengano trattate come stringhe. – Barak

risposta

0

Do not Pass Paramters gamma tipo in Query, a volte non funzionerà

int themes_id = themes_ids[m]; 

String stmtGetThemes = "SELECT * FROM pr_fields_descriptor a inner join pr_fields_starring b on a.id_fields_descriptor = b.fields_descriptor_id where b.starring_id = '"+pos_starring_id+"' AND a.theme_id = '"+themes_id+"' ORDER BY form_rank"; 

Cursor getThemesCursor1 = db.databaseQuery(stmtGetThemes); 

if (getThemesCursor1 != null && getThemesCursor1.getCount() != 0){ 
//---- 
} 
+0

Sono cambiato come hai detto tu, ma si blocca ancora. – Gabrielle

+0

controllare che lo spazio bianco sia utilizzato correttamente – RajeshVijayakumar

+0

Non vedo spazi bianchi che potrebbero causare un arresto anomalo. – Gabrielle

0
String stmtGetThemes = "SELECT * FROM pr_fields_descriptor a " 
    + "inner join pr_fields_starring b on a.id_fields_descriptor = b.fields_descriptor_id " 
    + "where b.starring_id = '"+pos_starring_id+"' and a.theme_id='"+themes_ids[m]+"' order by form_rank"; 

Non terminare questa query da ";".

Problemi correlati