0

I have a sqlite table. The point is that I want to select all rows where table field "name" is empty. In applying the code gives me error and I cannot fix. The following code:

ArrayList<String> smsContact = new ArrayList<String>();
    String nombre2 = "";
     baseDatos = openOrCreateDatabase(nombreBD, MODE_WORLD_WRITEABLE, null); 
   Cursor cur7 = baseDatos.rawQuery("SELECT nombre, telefono FROM memsajessmstotal WHERE nombre='" + nombre2 + "'", null);
   if ( cur7.getCount() < 0 || !cur7.moveToFirst() ) return;

    smsContact.clear();
   do {
        String nombre3 = "Desconocido";
        String telefono1 = cur7.getString(1);

        ContentValues valores = new ContentValues();
        valores.put("nombre",nombre3);

        //Actualizamos el registro en la base de datos
        baseDatos.update(tablaSMS1, valores, "telefono='" + telefono1 + "'", null);

   }
   while (cur7.moveToNext());

Thanks in advance.

Pankaj
  • 7,908
  • 6
  • 42
  • 65
user3068256
  • 61
  • 1
  • 5

1 Answers1

0

In most (if not all) relational databases, blank is different from null.

try this:

"SELECT nombre, telefono
 FROM memsajessmstotal
 WHERE nombre='" + nombre2 +
"' or nombre is null"
DwB
  • 37,124
  • 11
  • 56
  • 82