本帖最后由 amwtmoss 于 2012-02-28 16:25:15 编辑

解决方案 »

  1.   

    DB_TABLENAME ----  数据库表名
    String数组    ----  表中数据字段名
    privacy=1    ----   查询where语句
      

  2.   

    非常感谢,那么下面的哪些null呢?我是看的例子上这么写,上面没解释这个。
      

  3.   

    http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html
    查看query方法,形参名称很好的说明了它们的含义:
    query(String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy)
    如果你在selection中不写"privacy=1",而是"privacy=?"那么selectionArgs就是"?"应该填写的内容
      

  4.   

    public Cursor query (String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit)Since: API Level 1
    Query the given table, returning a Cursor over the result set.
    Parameterstable The table name to compile the query against.
    columns A list of which columns to return. Passing null will return all columns, which is discouraged to prevent reading data from storage that isn't going to be used.
    selection A filter declaring which rows to return, formatted as an SQL WHERE clause (excluding the WHERE itself). Passing null will return all rows for the given table.
    selectionArgs You may include ?s in selection, which will be replaced by the values from selectionArgs, in order that they appear in the selection. The values will be bound as Strings.
    groupBy A filter declaring how to group rows, formatted as an SQL GROUP BY clause (excluding the GROUP BY itself). Passing null will cause the rows to not be grouped.
    having A filter declare which row groups to include in the cursor, if row grouping is being used, formatted as an SQL HAVING clause (excluding the HAVING itself). Passing null will cause all row groups to be included, and is required when row grouping is not being used.
    orderBy How to order the rows, formatted as an SQL ORDER BY clause (excluding the ORDER BY itself). Passing null will use the default sort order, which may be unordered.
    limit Limits the number of rows returned by the query, formatted as LIMIT clause. Passing null denotes no LIMIT clause.
    ReturnsA Cursor object, which is positioned before the first entry. Note that Cursors are not synchronized, see the documentation for more details.