The following code (used to verify that a table exists) generates an
SQLITE_SCHEMA exception occasionally. This means the schema has
changed since the SQL statement was compiled.
It's noted in the SQLite documents that this only happens when using
sqlite3_prepare() and one should use sqlite3_prepare_v2() instead to
avoid this problem. Those function names refer to the C interface, not
Android Java. Does anyone know if Android's SQLiteDatabase.query
method uses sqlite3_prepare_v2() underneath? It would seem not. If
not, what is the recommended way to reliably query the list of tables
in a database?
String[] col = {"name"};
cursor = myDatabase.query(
/* table name */ "sqlite_master",
/* columns */ col,
/* select */ "type == 'table' AND name == '" +
tableName +
"'",
/* selection args */ null ,
/* no grouping */ null,
/* no grouping filter */ null,
/* ordering */ null
);
--
You received this message because you are subscribed to the Google
Groups "Android Developers" 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-developers?hl=en