The data in the database (with each line being accurate) is with each information.
Code from DBAPeter here (not all this, not all):
// field name: public static final string KEY_ROWID = "_id"; Public Stable Last String KEY_DEVICE = "Device"; Public static final string KEY_TYPE = "type"; Public static final string KEY_DEVID = "devid"; Public static final string [] ALL_KEYS = new string [] {KEY_ROWID, KEY_DEVICE, KEY_TYPE, KEY_DEVID}; Public static final string [] DEVID_KEY = new string [] {KEY_DEVID}; // Column number for each field name: Public static ending end COL_ROWID = 0; Public stable ending end COL_DEVICE = 1; Public fixed final distance COL_TYPE = 2; Public stable final end COL_DEVID = 3; // Database Information: public static final string DATABASE_NAME = "dbDevices"; Public static final string DATABASE_TABLE = "main device"; Public static final end DATABASE_VERSION = 10; // If there is a change in the DB structure, the version number should increase. // SQL statement database private static final String DATABASE_CREATE_SQL = 'CREATE TABLE "to + DATABASE_TABLE +" ( "+ KEY_ROWID +" integer primary key autoincrement, "+ KEY_DEVICE +" text is not NULL, "+ KEY_TYPE +" text "+ KEY_DEVID + "Text Taps" + ");"; Personal last reference references; Private databaseshelper MEDBehlper; Private SQLiteDatabase DB; // Get a specific line (by David) public string getDevName (String David) {name of string; String where = 'KEY_DEVID + "like'%" + devid + "% '"; Cursor c = db.query (true, databaseabable, ALL_KEYS, where, empty, empty, empty, zero, empty); C.moveToFirst (); Name = c.getString (COL_DEVICE); Name of return; } Here is the code that calls it:
string incoming message = ""; Incoming messages = in.readLine () + System.getProperty ("line.separator"); DevName = devDB.getDevName (incoming messages); And I know that this information is being received because it logs: whenever I run this I get the error: with the size of the index 0 03-16 15: 39: 47.122: W / system. Er (18073): On the Android database. Ebercursor Czech Pojiteshn (Abertkarsr. Java Sky 26) 03-16 15:39: 47.122 W / System.err (18073): On android.database.AbstractWindowedCursor.checkPosition (AbstractWindowedCursor.java:136) 03-16 15: 39: 47.132 W / System.err (18073): on android.database.AbstractWindowedCursor .getString (AbstractWindowedCursor.java:50) 03-16 15: 39: 47.132: W / System.err (18073): com.ti.cc3x.android .DBAdapter.getDevName (DBAdapter.java:121) 03-16 15: 39: 47.132: W / Systems. Er (18073): com.ti.cc3x.android.broadcastListener $ 1.run (broadcastListener.java:1212) 03-16 15: 39: 47.132: W / Systems. Er (18073): On Java.lang.Thread.run (read Read.java:841) I have not tried to check the tap cursor, whatever I do, Nothing says nothing. I know there is data where I am asking to ask this. I do not know why this will not show. Can anyone tell me where I went wrong? Thanks!
03-16 15: 39: 47.072: V / string (18073): 5122
03-16 15: 39: 47.122: W / System.err (18073): android.database.CursorIndexOutOfBoundsException>
To call getWritableDatabase () expand from @bwegs>.
To check selectionArgs Try to use return value moveToFirst () since to clear it, and turn your cursor Be sure to avoid memory leaks.
public string getDevName (string devid) {db = myDBHelper. GetWritableDatabase (); // Get DB if it is not already done, you can do string name = null already in the code shown; Where is the string = KEY_DEVID + "like?"; String [] selectionRAGE = new string [] {"%" + devid + "%"}; Cursor c = db.query (true, databaseabable, ALL_KEYS, where, selection order, empty, null, null, empty); // only uses the cursor, moveToFirst () succeeds // This will do this so that you do not get the CursorIndexOutOfBoundsException; (c.moveToFirst ()) {name = c.getString (COL_DEVICE); } C. Close (); // Close your cursor to avoid memory leakage! Db.close (); // Stop here if you call getWritableDatabase () at the beginning of this function, // it will return the tilt if there will be no result with a query return name; }
No comments:
Post a Comment