Android N Preview 3 - no such collation sequence: PHONEBOOK:

I was trying the Android N preview3 in my app.

Have a table which uses PHONEBOOK Collation.
Following is a sample create table query.

CREATE TABLE raw_contacts (
	_id INTEGER PRIMARY KEY AUTOINCREMENT,
	account_id INTEGER REFERENCES accounts(_id),
	sourceid TEXT,
	display_name_alt TEXT,
	display_name_source INTEGER NOT NULL DEFAULT 0,
	sort_key TEXT COLLATE PHONEBOOK,
	sort_key_alt TEXT COLLATE PHONEBOOK,
	name_verified INTEGER NOT NULL DEFAULT 0,
	sync1 TEXT 
);

Was getting an error which says net.sqlcipher.database.SQLiteException: no such collation sequence: PHONEBOOK:

PHONEBOOK is a different collation created on top of the existing collations which was working in a previous sql cipher version. Was it removed it in the latest release.

Also facing the same issue with COLLATE LOCALIZED.

Hello @Pratyul

The phonebook collator integration was based on extensions that relied on the ICU project which was removed from the new Android N Preview beta branch.

@developernotes
Thanks for the update. Any suggestions on the path forward
We can remove the collation from the app. But the concern is in upgrade scenario, is their any way we can remove this collation by executing a sql.

Hi @Pratyul

SQLite only supports renaming a table and adding columns for modifying the table schema. There are steps here that cover the process for making other types of changes such as these. Would you give that a try and let us know your results? Thanks

Finally was able to get to this. Tried the first step to copy contents to a new table, drop the existing table and rename the new table.
Also additionally had to recreate the indexes and views.

Hi @Pratyul

Thanks for getting back to us, we are glad to hear you were able to migrate successfully.

More on this. The collation drop logic works fine but apparently it works fine only till my app does not restart. Once the app is restarted I am seeing the following error "file is encrypted or is not a database: ".
Any suggestions on what might be the issue.

07-14 19:11:52.240: E/Database(11644): Failed to setLocale() when constructing, closing the database
07-14 19:11:52.240: E/Database(11644): net.sqlcipher.database.SQLiteException: file is encrypted or is not a database: , while compiling: select count(*) from sqlite_master;
07-14 19:11:52.240: E/Database(11644): at net.sqlcipher.database.SQLiteCompiledSql.native_compile(Native Method)
07-14 19:11:52.240: E/Database(11644): at net.sqlcipher.database.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
07-14 19:11:52.240: E/Database(11644): at net.sqlcipher.database.SQLiteCompiledSql.(SQLiteCompiledSql.java:64)
07-14 19:11:52.240: E/Database(11644): at net.sqlcipher.database.SQLiteProgram.(SQLiteProgram.java:83)
07-14 19:11:52.240: E/Database(11644): at net.sqlcipher.database.SQLiteQuery.(SQLiteQuery.java:49)
07-14 19:11:52.240: E/Database(11644): at net.sqlcipher.database.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
07-14 19:11:52.240: E/Database(11644): at net.sqlcipher.database.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1762)
07-14 19:11:52.240: E/Database(11644): at net.sqlcipher.database.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1727)
07-14 19:11:52.240: E/Database(11644): at net.sqlcipher.database.SQLiteDatabase.openDatabaseInternal(SQLiteDatabase.java:2344)
07-14 19:11:52.240: E/Database(11644): at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1091)
07-14 19:11:52.240: E/Database(11644): at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1154)
07-14 19:11:52.240: E/Database(11644): at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:162)
07-14 19:11:52.240: E/Database(11644): at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:129)

Hello @Pratyul

It appears you are still using an old version of SQLCipher for Android as the call to setLocale(…) were removed. You may wish to utilize the latest version of SQLCipher for Android which has been released. Instructions on integrating the library can be found here.