我尝试使用CursorLoader,但我不明白如何填写参数。
对于我的应用程序,如果值为false,我需要在一列中观察并获取此行的id。
String[] projection = {
TableLifetouchRespirationRate.COLUMN_ACKNOWLEDGMENT_MESSAGE
};
Context context = this;
Uri uri = IsansysPatientGatewayContentProvider.CONTENT_URI_RESPIRATION_RATES;
String selection = TableLifetouchRespirationRate.COLUMN_ACKNOWLEDGMENT_MESSAGE ;
String[] selectionArgs = null;
String sortOrder = null;
cursorLoader = new CursorLoader(context, uri, projection, selection + "=?", selectionArgs, sortOrder);
在SQL中它看起来像这样:
SELECT id FROM TableLifetouchRespirationRate WHERE acknolegment_message = false
你能给我一个使用游标加载器的例子吗?
答案 0 :(得分:1)
我找到了自己:)
Context context = this;
// URI table
Uri uri = IsansysPatientGatewayContentProvider.CONTENT_URI_RESPIRATION_RATES;
// URI columns to get from table class
String[] projection = {
TableLifetouchRespirationRate.COLUMN_ID,
TableLifetouchRespirationRate.COLUMN_LIFETOUCH_ID,
TableLifetouchRespirationRate.COLUMN_RESPIRATION_RATE,
TableLifetouchRespirationRate.COLUMN_ACKNOWLEDGMENT_MESSAGE,
TableLifetouchRespirationRate.COLUMN_TIMESTAMP,
TableLifetouchRespirationRate.COLUMN_SESSION_NUMBER
};
// In the column ACKNOWLEDGMENT_MESSAGE...
String selection = TableLifetouchRespirationRate.COLUMN_ACKNOWLEDGMENT_MESSAGE + "=?";
// Select rows = "0" (it is possible to add augments on several columns)
String[] selectionArgs = {"0"};
String sortOrder = null;
cursorLoader = new CursorLoader(context, uri, projection, selection, selectionArgs, sortOrder);
玩得开心!