I tried this two queries on a database which already has indexes defined:
myDB.rawQuery("drop index my_index", null);
myDB.rawQuery("create index my_index on mytable(row_table)", null);
And I get this error:
(1) index my_index already exists
And yet, when I do these very sames queries into a shell on my computer with sqlite3, it works perfectly!
What is wrong with these queries on Android?
You can add IF EXISTS clause to attempt to drop index only if it exists, thus avoiding an error about missing index:
database.execSQL("DROP INDEX IF EXISTS INDEX_NAME")
This worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With