List of usage examples for android.database Cursor setNotificationUri
void setNotificationUri(ContentResolver cr, Uri uri);
From source file:com.ubuntuone.android.files.provider.MetaUtilities.java
public static Cursor getVisibleVolumesCursor() { final Cursor c = sResolver.query(Volumes.CONTENT_URI, Volumes.getDefaultProjection(), null, null, null); c.setNotificationUri(sResolver, Volumes.CONTENT_URI); return c;/*from www . j ava 2 s . c om*/ }
From source file:com.ubuntuone.android.files.provider.MetaUtilities.java
public static Cursor getVisibleNodesCursorByParent(String parentPath) { final String showHidden = Preferences.getShowHidden() ? "" : " AND " + getHiddenSelection(); final String[] projection = Nodes.getDefaultProjection(); final String selection = Nodes.NODE_PARENT_PATH + "=? " + showHidden; final String[] selectionArgs = new String[] { parentPath }; final Cursor cursor = sResolver.query(Nodes.CONTENT_URI, projection, selection, selectionArgs, null); cursor.setNotificationUri(sResolver, Nodes.CONTENT_URI); return cursor; }
From source file:com.fabernovel.alertevoirie.data.CategoryProvider.java
@Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { JSONArray array = new JSONArray(); try {/*from w w w.ja v a 2 s.com*/ String categoryId = JsonData.VALUE_NULL; switch (uriMatcher.match(uri)) { case CATEGORIES_ID: categoryId = uri.getLastPathSegment(); //$FALL-THROUGH$ case CATEGORIES: JSONObject parent = categories.getJSONObject(categoryId); if (parent.has(JsonData.PARAM_CATEGORY_CHILDREN)) { JSONArray subset = parent.getJSONArray(JsonData.PARAM_CATEGORY_CHILDREN); for (int i = 0; i < subset.length(); i++) { JSONObject obj = categories.getJSONObject(subset.getString(i)); obj.put(BaseColumns._ID, (long) Integer.valueOf(subset.getString(i))); array.put(obj); } } break; case CATEGORY_ID: categoryId = uri.getLastPathSegment(); array.put(categories.getJSONObject(categoryId)); Log.d(Constants.PROJECT_TAG, "category returned = " + categories.getJSONObject(categoryId)); break; default: return null; } } catch (NumberFormatException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } Cursor c = new JSONCursor(array, projection); if (c != null) c.setNotificationUri(getContext().getContentResolver(), uri); return c; }
From source file:com.manning.androidhacks.hack043.provider.MySQLContentProvider.java
@Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); switch (sUriMatcher.match(uri)) { case ITEM://from www. j a v a 2 s . c o m qb.setTables(TABLE_NAME); qb.setProjectionMap(projectionMap); break; case ITEM_ID: qb.setTables(TABLE_NAME); qb.setProjectionMap(projectionMap); qb.appendWhere(COLUMN_ID + "=" + uri.getPathSegments().get(1)); break; default: throw new RuntimeException("Unknown URI"); } SQLiteDatabase db = getDatabaseHelper().getReadableDatabase(); Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, sortOrder); c.setNotificationUri(getContext().getContentResolver(), uri); return c; }
From source file:com.manning.androidhacks.hack043.provider.BatchNumbersContentProvider.java
@Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); switch (sUriMatcher.match(uri)) { case ITEM://w w w. j av a 2s . c o m qb.setTables(TABLE_NAME); qb.setProjectionMap(projectionMap); break; case ITEM_ID: qb.setTables(TABLE_NAME); qb.setProjectionMap(projectionMap); qb.appendWhere(COLUMN_ID + "=" + uri.getPathSegments().get(1)); break; default: throw new RuntimeException("Unknown URI"); } SQLiteDatabase db = dbHelper.getReadableDatabase(); Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, sortOrder); c.setNotificationUri(getContext().getContentResolver(), uri); return c; }
From source file:com.manning.androidhacks.hack023.provider.TodoContentProvider.java
@Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); switch (sUriMatcher.match(uri)) { case TODO:/*from w w w . ja va 2s .co m*/ qb.setTables(TODO_TABLE_NAME); qb.setProjectionMap(projectionMap); break; case TODO_ID: qb.setTables(TODO_TABLE_NAME); qb.setProjectionMap(projectionMap); qb.appendWhere(COLUMN_ID + "=" + uri.getPathSegments().get(1)); break; default: throw new RuntimeException("Unknown URI"); } SQLiteDatabase db = dbHelper.getReadableDatabase(); Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, sortOrder); c.setNotificationUri(getContext().getContentResolver(), uri); return c; }
From source file:com.revesoft.itelmobiledialer.util.SQLiteCursorLoader.java
/** * Registers an observer to get notifications from the content provider * when the cursor needs to be refreshed. *//* w w w. ja va2 s. c o m*/ public void registerContentObserver(Cursor cursor, Uri observerUri) { cursor.registerContentObserver(mObserver); cursor.setNotificationUri(getContext().getContentResolver(), observerUri); }
From source file:fr.shywim.antoinedaniel.ui.fragment.SoundFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { if (cursor.isClosed()) { getLoaderManager().restartLoader(mContentId, null, this); return;/* w ww .j a v a 2 s. c o m*/ } if (loader.getId() == MainActivity.LoaderID.SOUND_FILTER) { cursor.setNotificationUri(mContext.getContentResolver(), ProviderConstants.PLAYLIST_URI); } ((CursorRecyclerAdapter) mSoundList.getAdapter()).swapCursor(cursor); }
From source file:io.github.hidroh.materialistic.data.FavoriteManager.java
@Override public void attach(@NonNull Context context, @NonNull LoaderManager loaderManager, @NonNull Observer observer, String filter) {// w w w . jav a 2 s .c o m loaderManager.restartLoader(FavoriteManager.LOADER, null, new LoaderManager.LoaderCallbacks<android.database.Cursor>() { @Override public Loader<android.database.Cursor> onCreateLoader(int id, Bundle args) { if (!TextUtils.isEmpty(filter)) { return new FavoriteManager.CursorLoader(context, filter); } return new FavoriteManager.CursorLoader(context); } @Override public void onLoadFinished(Loader<android.database.Cursor> loader, android.database.Cursor data) { if (data != null) { data.setNotificationUri(context.getContentResolver(), MaterialisticProvider.URI_FAVORITE); mCursor = new Cursor(data); } else { mCursor = null; } observer.onChanged(); } @Override public void onLoaderReset(Loader<android.database.Cursor> loader) { mCursor = null; observer.onChanged(); } }); }
From source file:org.coocood.vcontentprovider.VContentProvider.java
@Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { String table = getTableName(uri); String idPath = getIdPath(uri); db = mOpenHelper.getReadableDatabase(); Cursor c = db.query(table, projection, finalSelection(idPath, selection), selectionArgs, null, null, sortOrder);/* w ww . j a v a2 s . co m*/ c.setNotificationUri(getContext().getContentResolver(), uri); return c; }