黑莓应用程序非常慢,为什么在循环中使用Sqlite查询

时间:2013-09-20 16:07:20

标签: sqlite blackberry

我正在使用bb app,app已经完成但是从sqlite中选择数据时速度非常慢,我无法找到任何提升性能的解决方案,请参阅下面的代码

for(int a=0;a<200;a++){
   retrieveCode(selectQuery);
}

,其中

public String retrieveCode(String query)
{
    String s = "";   
    Vector v = new Vector();

    try
    {
        g.vec_Result = new Vector();

        // Read in all records from the Category table
        Statement statement = _db.createStatement(query);//"SELECT * FROM samples"

        statement.prepare();
        Cursor cursor = statement.getCursor();              

        Row row;
        // Iterate through the result set.  For each row, create a new
        // Category object and add it to the hash table. 
        while(cursor.next())
        {
             row = cursor.getRow();

             s = row.getString(0);
             v.addElement(vmd);
        }
        statement.close();
        cursor.close();
    }
    catch(DatabaseException dbe)
    {
        g.errorDialog(dbe.toString());
    }
    catch(DataTypeException dte)
    {
        g.errorDialog(dte.toString());
    }
    s = v.firstElement().toString();
    return s;    
}

我正在为OS5.0开发,请帮助

0 个答案:

没有答案