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.

inside custom component

Java Development

Reply
Highlighted
Developer
Posts: 228
Registered: ‎10-01-2011
My Device: Passport

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.

 

Developer
Posts: 228
Registered: ‎10-01-2011
My Device: Passport

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();
}
}