Categories
android null sqlite

Android SQLite select IS NOT NULL

I’m trying to retrieve only the data that are not NULL in a database table, but the IS NOT NULL clause does not seem to work. The null fields are also displayed.

String sql = "SELECT _id, nome_sotto FROM Categorie
WHERE nome_categoria=""+i.getStringExtra("categoria")+""
AND nome_sotto IS NOT NULL ORDER BY nome_sotto ASC";


private void list() {
SQLiteDatabase db = mHelper.getReadableDatabase();
final List<Dettaglio> dettagli = new ArrayList<Dettaglio>();
String sql = "SELECT _id, nome_sotto FROM Categorie
WHERE nome_categoria=""+i.getStringExtra("categoria")+""
AND nome_sotto IS NOT NULL ORDER BY nome_sotto ASC";
Cursor c = db.rawQuery(sql, null);
while (c.moveToNext()){
Dettaglio d = new Dettaglio();
d.id = c.getString(0);
d.sottocat = c.getString(1);
dettagli.add(d);
}
c.close();
db.close();
ListAdapter adapter....
}