-1

I am new to database and I am trying to get all the data from table whose category column is equal to 1. This is my first attempt. Can someone please guide me where I am doing wrong?

public Cursor getAllFamilyMovies()
    {
        return database.query("movies", new String[] {"_id", "name"},
                "category=1", null, null, null, "name");
}
Kamil Kamili
  • 1,757
  • 5
  • 24
  • 39

1 Answers1

1

The "whereclause" and "whereargs" need to be separated as shown below:

public Cursor getAllFamilyMovies() {
    return database.query("movies", new String[] {"_id", "name"}, "category = ?", new String[] {"1"}, null, null, "name");
}
guipivoto
  • 18,327
  • 9
  • 60
  • 75
hello404
  • 22
  • 2