Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use Autocomplete Field with sqlite?
    text
    copied!<p>I'm trying to use this code. Which is an auto-complete field that use the database.</p> <pre class="lang-java prettyprint-override"><code>import java.util.Vector; import net.rim.device.api.collection.util.*; import net.rim.device.api.database.Cursor; import net.rim.device.api.database.Database; import net.rim.device.api.database.DatabaseFactory; import net.rim.device.api.database.Row; import net.rim.device.api.database.Statement; import net.rim.device.api.ui.*; import net.rim.device.api.ui.container.*; import net.rim.device.api.ui.component.*; public class AutoCompleteFieldDemo extends UiApplication { public static void main(String[] args) { AutoCompleteFieldDemo app = new AutoCompleteFieldDemo(); app.enterEventDispatcher(); } public AutoCompleteFieldDemo() { pushScreen(new AutoCompleteFieldDemoScreen()); } public static String[] getDataFromDB() { Vector names = new Vector(); try { Database db = DatabaseFactory.openOrCreate("database1.db"); Statement statement1 = db.createStatement("SELECT name FROM Directory_Items"); statement1.prepare(); statement1.execute(); Cursor c = statement1.getCursor(); Row r; while(c.next()) { r = c.getRow(); names.addElement(r.getString(0)); } statement1.close(); db.close(); } catch( Exception e ) { System.out.println( e.getMessage() ); e.printStackTrace(); } String [] returnValues = new String[names.size()]; for (int i = 0; i &lt; names.size(); i++) { returnValues[i] = (String) names.elementAt(i); } return returnValues; } static final class AutoCompleteFieldDemoScreen extends MainScreen { AutoCompleteFieldDemoScreen() { BasicFilteredList filterLst = new BasicFilteredList(); filterLst.addDataSet(1,getDataFromDB() ,"Names",BasicFilteredList.COMPARISON_IGNORE_CASE)​; AutoCompleteField autoFld = new AutoCompleteField(filterLst); add(autoFld); } </code></pre> <p><a href="http://supportforums.blackberry.com/t5/Java-Develo%E2%80%8Bpment/Autocomplete-textfield/m-p/1730311#M199761" rel="nofollow">I found it in here</a></p> <p>The problem that I'm facing is, I can't find the database. I have created the database in the SD card and I put the name in the createOropen("myDataBase.db). But When I debug it jump to the exception. Any idea about why I'm having this problem.</p> <p>Thank you so much!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload