Compare a SQLite field in Android Studio

0

I am trying to compare a field named NAME of type TEXT with a variable that I have in another activity, how could I get that field that contains the name of a user and be able to compare it?

    
asked by German Silva 25.10.2018 в 01:42
source

1 answer

0

It would be something like this.

public Cursor consultar(String busqueda) {
        SQLiteDatabase db = this.getReadableDatabase();
        Cursor cursor = null;
        if(busqueda != null) {
            cursor = db.query(TABLE_PROVEEDORES, new String[]{ID, NOMBRE, FECHA}, NOMBRE + " LIKE?", new String[]{busqueda+"%"}, null, null, null);
        }
        if (cursor != null) {
            cursor.moveToFirst();
            return cursor;
        } else {
            return null;
        }
    }

this will return a course in this case use the clause LIKE , and just call this method and you returned a cursor, and with that you access the information you need.

    
answered by 25.10.2018 в 01:52