A
A
Alexey2018-08-11 21:15:33
Android
Alexey, 2018-08-11 21:15:33

Why does a SQLite query sometimes return an empty result?

The application uses a SQLite database with 13 columns.
When columns from 1st to 7th are used in the request parameters for getting or deleting a note, the request passes, if from 8th to last - 0 rows are always returned.
Let's say here is the query when searching the db

private NoteCursorWrapper querySeach(String stringSearch) {
    Cursor cursor = mDatabase.query(
        NoteTable.NAME_NT,
        null,	//Columns - select all columns
        NoteTable.Cols_note.TITLE_N + " LIKE ? OR " + NoteTable.Cols_note.TEXT_N + " LIKE ?",
        new String[] {"%"+ stringSearch + "%", "%"+ stringSearch + "%"},
        null,	//groupBy
        null,	//having
        NoteTable.Cols_note.DATE_CREATED_N + " DESC"//
      );
    
    return new NoteCursorWrapper(cursor);
}

In NoteTable.Cols_note.TITLE_N and NoteTable.Cols_note.TEXT_N the names of the 6th and 7th columns.
But even this query (getting encrypted records) always returns 0 rows, even if the NoteTable.Cols_note.ENCRYPT_STATUS_N column is set to 1. The column is the 8th one.
private NoteCursorWrapper querySeach(String stringSearch) {
  Cursor cursor = mDatabase.query(
      NoteTable.NAME_NT,
      null,	//Columns - select all columns
      NoteTable.Cols_note.ENCRYPT_STATUS_N + " =? ",
      new String[] {"1"},
      null,	//groupBy
      null,	//having
      null//
    );
    
  return new NoteCursorWrapper(cursor);
}

You have to pervert - get all the notes, and then filter by encryption status or another parameter.
What could be the problem? And how to solve it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question