Hi,
I am new to Android and SQLite. I am trying to query a table on a non
primary key column. Is this possible? FYI, I am able to create, insert
and retrieve all rows. The structure of the table is as follows:
.....
private static final String DATABASE_NAME = "WordSolver";
private static final String DATABASE_TABLE = "words";
public static final String KEY_ROWID = "_id";
public static final String KEY_WORD = "word";
.....
private static final String DATABASE_CREATE = "CREATE TABLE "+
DATABASE_TABLE+
"("+ KEY_ROWID +" INTEGER PRIMARY KEY,"+
KEY_WORD +" TEXT);";
.......
//Method to retrieve by word
public Cursor getWord(String word) throws SQLException
{
//db is the SQLiteDatabase
Cursor c = db.query(DATABASE_TABLE, new String[]{KEY_WORD},
KEY_WORD+"="+word, new String[]{KEY_WORD},null,null,null);
if (c != null) {
c.moveToFirst();
}
return c;
}
.......
This always errors on the query. Is it not possible to query on a non
primary key column? Or is there something else I am missing. Any help
will be very appreciated.
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en