如何显示CursorLoader的SQL查询

时间:2016-12-22 16:25:05

标签: android android-sqlite android-cursorloader

我想在Log.dCursorLoader显示onCreateLoader方法中 return new CursorLoader( getActivity(), // Parent activity context WifiEntry.CONTENT_URI, // Provider content URI to query projection, // Columns to include in the resulting Cursor null, // No selection clause null, // No selection arguments WifiEntry.COLUMN_WIFI_NAME + " ASC"); 生成的当前SQL查询,例如:

@Override
public Cursor query(Uri uri, String[] projection, String selection,
                    String[] selectionArgs, String sortOrder)
{
    // Get readable database
    SQLiteDatabase database = mDbHelper.getReadableDatabase();
    // This cursor will hold the result of the query
    Cursor cursor;

    // Figure out if the URI matcher can match the URI to a specific code
    int match = sUriMatcher.match(uri);
    switch (match)
    {
        case WIFIS:
            // For the WIFIS code, query the wifi table directly with the given
            // projection, selection, selection arguments, and sort order. The cursor
            // could contain multiple rows of the pets table.
            cursor = database.query(WifiEntry.TABLE_NAME, projection, selection, selectionArgs,
                    null, null, sortOrder);
            break;
        case WIFI_ID:
            // For the WIFI_ID code, extract out the ID from the URI.
            // the selection will be "_id=?"
            selection = WifiEntry._ID + "=?";
            selectionArgs = new String[] { String.valueOf(ContentUris.parseId(uri)) };
            cursor = database.query(WifiEntry.TABLE_NAME, projection, selection, selectionArgs,
                    null, null, sortOrder);
            break;
        default:
            throw new IllegalArgumentException("Cannot query, unknown URI " + uri);
    }
    cursor.setNotificationUri(getContext().getContentResolver(), uri);

    // Return the cursor
    return cursor;
}

我查看了Android文档,并且在这里,但没有成功。调试目的是为了能够可视化SQL字符串。

谢谢!

更新即可。我正在添加ContentProvider查询方法,任何人都可以回答如何在Log中显示生成的SQL查询? 感谢。

{{1}}

0 个答案:

没有答案