1

I'm using a tutorial here to provide an AutoCompleteTextView with a SimpleCursorAdapter. It works perfectly as is, but I've changed the database to use fts3 because I've heard it's faster (hence, the name).

It seems something in the code is hard-wired to use the column _id because after changing to an fts3 table, I get this error:

01-28 21:31:53.018: E/AndroidRuntime(16284): java.lang.IllegalArgumentException: column '_id' does not exist
01-28 21:31:53.018: E/AndroidRuntime(16284): at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:314)

Even though I haven't declared the autoincrement key anywhere (as it's superceded by rowid in fts3). The error occurs in AbstractCursor, so there's not much I can do about it.

I'm thinking there might be a way to force the code to recognize rowid as _id by using SELECT rowid,* FROM mytable and then changing the column name somehow.. I'm pretty new to sql so any help is appreciated!

Snailer
  • 3,777
  • 3
  • 35
  • 46

1 Answers1

1

Renaming a column in SQLite can be done as described here. Note that it is highly advisable to do all these operations in transaction. One detail when you are doing this in Android - I don't know how you execute sql scripts in your solution, but keep in mind this if you use execSQL calls.

By the way if you prefer not to rename the column you can try the technique proposed here.

Community
  • 1
  • 1
Boris Strandjev
  • 46,145
  • 15
  • 108
  • 135