Creating unique index fails for unknown database exception in Android -
my database has been working application before mysterious problem. wanted add together unique index in 1 table (listitems) 2 columns (list_id , item_id). table keeps track of items associated each list , don't want there duplicates in lists.
so wrote database upgrade method called onupgrade(...)
private void upgradeto3(sqlitedatabase db) { db.execsql("create unique index if not exists '"+ contract.database_name +"'.list_item_unique_index on "+ contract.listitem.tablename + " ( "+ contract.listitem.list +", " + contract.listitem.item + ")"); }
and gives me error "unknown database 'my_database.db'"
i'm getting database helper constructor uses same string sql above, here doesn't throw error. , can access database.
public databasehelper(context context) { super(context, contract.database_name, null, contract.database_version); }
also if open ddms in eclipse can see there file named 'my_database.db' within application files.
does have thought why database doesn't seem exist in sql execution?
went http://www.sqlite.org/lang_createindex.html , noticed name of database optional in command. removed command should know database going operate. , works.
android android-sqlite
No comments:
Post a Comment