开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜