Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Posts: 43
Registered: ‎07-22-2012
My Device: curve
My Carrier: syudent

Make function return cursor

can i make function that return cursor and then i use this cursor when i call the function please any body give me example for this

thanks advanced

New Contributor
Posts: 4
Registered: ‎09-16-2012
My Device: Simulator
My Carrier: MTS

Re: Make function return cursor

[ Edited ]

There are many ways to do so.

A simple example code:

Database db;

void getCursor(String sql){
    CursorAdapter cursorAdapter = CursorAdapter.create(db, sql);
    Cursor cursor = cursorAdapter.getCursor();
//use cursor here...

class CursorAdapter{

static CursorAdapter create(Database db, String sql){
    return new CursorAdapter(db, sql);

Cursor cursor;

CursorAdapter(Database db, String sql){
    Statement stmt = db.createStatement(sql);
    cursor = stmt.getCursor();

Cursor getCursor(){
    return cursor;

void close(){


More complex way is to implement Cursor interface in your class an use default RIM cursor as delegate.