How can I get this SQLite query to work? [duplicate]
When executing the query below, I get a "Stopped Unexpectedly" error.
I am trying to pull only records that contain "movie"
, in my "KEY_TYPE"
column from my android Sql table.
This is what I have right now:
/** Called when the activity is first created. */
@Override public void onCreat开发者_如何学Pythone(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.media_list);
setTitle(R.string.movie_list);
mDb.query("records", new String[] {MediaDbAdapter.KEY_TYPE}, "KEY_TYPE LIKE '%movie%'", null, null, null, null);
I think this is a simple quoting problem:
mDb.query("records", new String[] {MediaDbAdapter.KEY_TYPE}, "KEY_TYPE LIKE '%movie%'", null, null, null, null);
It looks like you need something like
mDb.query("records", new String[] {MediaDbAdapter.KEY_TYPE}, "KEY_TYPE LIKE '%movie%'", null, null, null, null);
The % signs around "movie" tell the SQL engine to search for records that contain the string "movie" somewhere in them.
精彩评论