Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
crispyoz
Posts: 223
Registered: ‎10-01-2011

Re: sqllite checking for values

Just add a return false to the catch :

 

} catch Exception e) {
    e.printStackTrace();

    return false;

 

Because if it does throw an exception it would not return any result otherwise. But that is java logic, nothing really to do with blackberry coding.

 

Please use plain text.
Developer
crispyoz
Posts: 223
Registered: ‎10-01-2011

Re: sqllite checking for values

Actually even though this is not a blackberry specific point, you should really close the statement and db in a finally block like this:

 

 

Cursor crsr = stmt.getCursor();
if (crsr.next())
return true;
else
return false;
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
if (stmt!=null)
try {
stmt.close();
} catch (DatabaseException e) {
e.printStackTrace();
}
if (db!=null)
try {
db.close();
} catch (DatabaseIOException e) {
e.printStackTrace();
}
}

Please use plain text.