开发者

How can I get this SQLite query to work? [duplicate]

开发者 https://www.devze.com 2023-03-30 19:23 出处:网络
This question already has answers here: Closed 11 years ago. When executing the query below, I get a \"Stopped Unexpectedly\" error.
This question already has answers here: Closed 11 years ago.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消