From 96e277c7ba7aae0cb216be5d5ec210ba7523b073 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 20 Sep 2012 07:29:00 -0700 Subject: [PATCH] don't offer to copy DB from sdcard when there is none. --- .../XWords4/src/org/eehouse/android/xw4/DBUtils.java | 8 ++++++++ .../XWords4/src/org/eehouse/android/xw4/GamesList.java | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java index 477a679ab..a036cc9e4 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java @@ -1146,6 +1146,14 @@ public class DBUtils { } } + public static boolean gameDBExists( Context context ) + { + String name = DBHelper.getDBName(); + File sdcardDB = new File( Environment.getExternalStorageDirectory(), + name ); + return sdcardDB.exists(); + } + private static void copyGameDB( Context context, boolean toSDCard ) { String name = DBHelper.getDBName(); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java index 2d8f3b2ec..93eca3af1 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java @@ -545,6 +545,12 @@ public class GamesList extends XWListActivity MenuItem item = menu.findItem( id ); item.setVisible( visible ); } + + if ( visible && !DBUtils.gameDBExists( this ) ) { + MenuItem item = menu.findItem( R.id.gamel_menu_loaddb ); + item.setVisible( false ); + } + return super.onPrepareOptionsMenu( menu ); }