set initial rowID based on clock to avoid duplicates after an

uninstall/reinstall.
This commit is contained in:
Eric House 2013-01-29 08:01:14 -08:00
parent c75ecef240
commit f3a063698c

View file

@ -169,6 +169,7 @@ public class DBHelper extends SQLiteOpenHelper {
createTable( db, TABLE_NAME_OBITS, s_obitsColsAndTypes );
createTable( db, TABLE_NAME_DICTINFO, s_dictInfoColsAndTypes );
createTable( db, TABLE_NAME_DICTBROWSE, s_dictBrowseColsAndTypes );
forceRowidHigh( db, TABLE_NAME_SUM );
createGroupsTable( db );
}
@ -303,6 +304,7 @@ public class DBHelper extends SQLiteOpenHelper {
db.execSQL( query );
}
createTable( db, name, data );
forceRowidHigh( db, name );
if ( null != columnNames ) {
ArrayList<String> oldCols =
@ -333,4 +335,16 @@ public class DBHelper extends SQLiteOpenHelper {
dest, src );
db.execSQL( query );
}
private void forceRowidHigh( SQLiteDatabase db, String name )
{
long now = Utils.getCurSeconds();
// knock 20 years off; whose clock can be that far back?
now -= 622080000;
String query = String.format( "INSERT INTO %s (rowid) VALUES (%d)",
name, now );
db.execSQL( query );
query = String.format( "DELETE FROM %s", name );
db.execSQL( query );
}
}