Example usage for android.database MergeCursor setNotificationUri

List of usage examples for android.database MergeCursor setNotificationUri

Introduction

In this page you can find the example usage for android.database MergeCursor setNotificationUri.

Prototype

@Override
public void setNotificationUri(ContentResolver cr, Uri notifyUri) 

Source Link

Document

Specifies a content URI to watch for changes.

Usage

From source file:com.ubuntuone.android.files.provider.MetaUtilities.java

public static Cursor getVisibleTopNodesCursor() {
    // XXX android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1
    final String showHidden = Preferences.getShowHidden() ? "" : " AND " + getHiddenSelection();
    final String[] projection = Nodes.getDefaultProjection();

    String selection = Nodes.NODE_RESOURCE_PATH + "=?" + showHidden;
    String[] selectionArgs = new String[] { Preferences.U1_RESOURCE };
    final Cursor ubuntuOne = sResolver.query(Nodes.CONTENT_URI, projection, selection, selectionArgs, null);

    selection = Nodes.NODE_RESOURCE_PATH + "=?" + showHidden;
    selectionArgs = new String[] { Preferences.U1_PURCHASED_MUSIC };
    final Cursor purchasedMusic = sResolver.query(Nodes.CONTENT_URI, projection, selection, selectionArgs,
            null);/*from  w w w .j  ava2s.c  om*/

    selection = Nodes.NODE_PARENT_PATH + " IS NULL " + "AND " + Nodes.NODE_RESOURCE_PATH + "!=? " + "AND "
            + Nodes.NODE_RESOURCE_PATH + "!=? " + showHidden;
    selectionArgs = new String[] { Preferences.U1_RESOURCE, Preferences.U1_PURCHASED_MUSIC };
    final Cursor cloudFolders = sResolver.query(Nodes.CONTENT_URI, projection, selection, selectionArgs, null);

    final MergeCursor cursor = new MergeCursor(new Cursor[] { ubuntuOne, purchasedMusic, cloudFolders });
    cursor.setNotificationUri(sResolver, Nodes.CONTENT_URI);

    return cursor;
}