Skip to content

Instantly share code, notes, and snippets.

@cyrilmottier
Created April 2, 2013 13:39
Show Gist options
  • Save cyrilmottier/5292270 to your computer and use it in GitHub Desktop.
Save cyrilmottier/5292270 to your computer and use it in GitHub Desktop.
Passing additional information into a Cursor
package com.cyrilmottier.android.avelov.database;
import android.database.Cursor;
import android.database.CursorWrapper;
import android.os.Bundle;
/**
* A Cursor that completely re-writes the actual Cursor capabilities related to extras. It allows clients to use the setExtras(Bundle) (this
* method is actually hidden in the Android framework).
*
* @author Cyril Mottier
*/
public class MetaCursor extends CursorWrapper {
private Bundle mExtras = Bundle.EMPTY;
public MetaCursor(Cursor cursor) {
super(cursor);
}
/**
* Sets a {@link android.os.Bundle} that will be returned by {@link #getExtras()}. <code>null</code> will be converted into {@link
* android.os.Bundle#EMPTY}.
*
* @param extras {@link android.os.Bundle} to set.
*/
public void setExtras(Bundle extras) {
mExtras = extras == null ? Bundle.EMPTY : extras;
}
@Override
public Bundle getExtras() {
return mExtras;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment