mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-07 05:24:46 +01:00
use a different name for each variant's db when written to SD card so
they don't overwrite each other's.
This commit is contained in:
parent
b8c597ab98
commit
07dd7f2eed
4 changed files with 27 additions and 5 deletions
|
@ -2,3 +2,4 @@ BasEnglish2to8.xwd
|
|||
CollegeEng_2to8.xwd
|
||||
Top5000.xwd
|
||||
changes.html
|
||||
gitvers.txt
|
||||
|
|
|
@ -124,3 +124,4 @@ RelayInviteDelegate.java
|
|||
XWConnAddrPreference.java
|
||||
XWDevIDPreference.java
|
||||
XWExpListAdapter.java
|
||||
RequestCode.java
|
||||
|
|
|
@ -1774,10 +1774,15 @@ public class DBUtils {
|
|||
|
||||
public static boolean gameDBExists( Context context )
|
||||
{
|
||||
String name = DBHelper.getDBName();
|
||||
File sdcardDB = new File( Environment.getExternalStorageDirectory(),
|
||||
name );
|
||||
return sdcardDB.exists();
|
||||
String varName = getVariantDBName();
|
||||
boolean exists = new File( Environment.getExternalStorageDirectory(),
|
||||
varName ).exists();
|
||||
if ( !exists ) {
|
||||
// try the old one
|
||||
exists = new File( Environment.getExternalStorageDirectory(),
|
||||
DBHelper.getDBName() ).exists();
|
||||
}
|
||||
return exists;
|
||||
}
|
||||
|
||||
public static String[] getColumns( SQLiteDatabase db, String name )
|
||||
|
@ -2128,8 +2133,16 @@ public class DBUtils {
|
|||
{
|
||||
String name = DBHelper.getDBName();
|
||||
File gamesDB = context.getDatabasePath( name );
|
||||
|
||||
// Use the variant name EXCEPT where we're copying from sdCard and
|
||||
// only the older name exists.
|
||||
File sdcardDB = new File( Environment.getExternalStorageDirectory(),
|
||||
name );
|
||||
getVariantDBName() );
|
||||
if ( !toSDCard && !sdcardDB.exists() ) {
|
||||
sdcardDB = new File( Environment.getExternalStorageDirectory(),
|
||||
name );
|
||||
}
|
||||
|
||||
try {
|
||||
File srcDB = toSDCard? gamesDB : sdcardDB;
|
||||
if ( srcDB.exists() ) {
|
||||
|
@ -2144,6 +2157,12 @@ public class DBUtils {
|
|||
}
|
||||
}
|
||||
|
||||
private static String getVariantDBName()
|
||||
{
|
||||
return String.format( "%s_%s", DBHelper.getDBName(),
|
||||
BuildConstants.VARIANT );
|
||||
}
|
||||
|
||||
// Chat is independent of the GameLock mechanism because it's not
|
||||
// touching the SNAPSHOT column.
|
||||
private static void saveChatHistory( Context context, long rowid,
|
||||
|
|
|
@ -114,6 +114,7 @@ class BuildConstants {
|
|||
public static final boolean THUMBNAIL_SUPPORTED = $THUMBNAIL_SUPPORTED;
|
||||
public static final long BUILD_STAMP = $(date +'%s');
|
||||
public static final String DBG_TAG = "$DBG_TAG";
|
||||
public static final String VARIANT = "$VARIANT";
|
||||
}
|
||||
EOF
|
||||
|
||||
|
|
Loading…
Reference in a new issue