Hi,I don't got what you mean.
@Override
public Cursor query(Uri uri, String[] projection, String
selection, String[] selectionArgs,
String sort) {
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(TASKS_TABLE);
String orderBy;
if (TextUtils.isEmpty(sort)) {
orderBy = TASK_COMPLETED + " DESC" + ", " + TASK_PRIORITY
+ ", " + TASK_ID;
} else {
orderBy = sort;
}
switch (mURIMatcher.match(uri)) {
case TASKS_SINGLE:
qb.appendWhere(TASK_ID + "=" + uri.getPathSegments().get(1));
break;
default:
break;
}
Cursor c = qb.query(mTasksDb,
projection,
selection, selectionArgs,
null, null,
orderBy);
c.setNotificationUri(getContext().getContentResolver(), uri);
return c;
}
In above query implementation for content provider,
can I delete the line c.setNotificationUri(getContext().getContentResolver(),
uri) ??
thanks
2009/4/22 Marco Nelissen <[email protected]>
> On Wed, Apr 22, 2009 at 2:48 AM, aby <[email protected]> wrote:
>
>>
>>
>> In the sample code of android developer
>>
>> http://developer.android.com/reference/android/content/ContentProvider.html
>>
>> When query the content provider, the cursor in query () call
>> setNotificationUri(getContext().getContentResolver(), uri).
>>
>> But the query is a read-data action, it doesn't need to notify uri
>> because the database can't update when being read. is there any
>> propose to avoid some problem adding setNotificationUri in the query
>> function of content provider?
>
>
> The notification is for when the data changes after the cursor has been
> created, so that whoever has the cursor is notified that the data in the
> cursor is now stale, and the cursor should be requeried.
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---