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

What's wrong in the cursor return type of this function

i have fuction that return cursor 

public Cursor getAllCounries() {
		Statement st = null;
		try {
			st = db.createStatement("select [" + KEY_COUNTRY_ID + "],["
					+ "] From [" + DATABASE_TABLE_COUNTRY + "] order by ["
					+ KEY_COUNTRY_Name + "]");
			Cursor c = st.getCursor();
			return c;
		} catch (Exception e) {
			return null;
		} finally {
			try {
			} catch (Exception e) {

 but when i call the function the cursor is unll although he select data and if i use cursor in the function work right and cursor not null but when call it return cursor but have problem please anybody help me

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

Re: What's wrong in the cursor return type of this function

Do not not close the statement before you read and close the cursor.
In your code finally block executes before you function returns the cursor so it returns with closed statement.