I have an application which runs fine under BlackBerry OS 7.0, but when I run the same application under BlackBerry OS 6.0, the SqLite cursor reaches the end of the data immediately, so I can’t fetch any data from the database.
public static Vector GetProducts(String sysID) {
Bitmap img = null;
try {
Statement st = d
.createStatement("SELECT * FROM Product where systemSerID=?");
st.prepare();
st.bind(1, sysID);
st.execute();
Cursor c = st.getCursor();
Products products;
Vector pro = new Vector();
while (c.next()) {
Row r = c.getRow();
products = new Products();
products.setSystemServiceID(r.getString(1));
products.setSystemServiceName(r.getString(2));
products.setProductID(r.getString(3));
products.setProductName(r.getString(4));
products.setProductDesc(r.getString(5));
products.setProductType(r.getString(devil));
// products[i].setProductType("1");
products.setBatchID(r.getString(7));
products.setMinValue(r.getString(music));
products.setMaxValue(r.getString(9));
products.setImageURL(r.getString(10));
System.out.println(" retrived from database.");
pro.addElement(products);
}
c.close();
st.close();
return pro;
} catch (DatabaseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
} catch (DataTypeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
The documentation for Database says:
Since you want to access a result set, you shouldn’t call Statement.execute(). getCursor() causes the query to execute, so you should be able to delete the execute() call to get the behavior you want.