From 901e07c0aaa648db6c8683e0486628d2c7ff31f6 Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 18 Apr 2014 08:02:25 -0700 Subject: [PATCH] getter for new pairs DB --- .../src/org/eehouse/android/xw4/DBUtils.java | 21 +++++++++++++++++++ 1 file changed, 21 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 dd952f7c3..b8cd8ca70 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java @@ -1786,6 +1786,27 @@ public class DBUtils { return result; } + public static String getStringFor( Context context, String key, String dflt ) + { + String selection = String.format( "%s = '%s'", DBHelper.KEY, key ); + String[] columns = { DBHelper.VALUE }; + + initDB( context ); + synchronized( s_dbHelper ) { + SQLiteDatabase db = s_dbHelper.getReadableDatabase(); + Cursor cursor = db.query( DBHelper.TABLE_NAME_PAIRS, columns, + selection, null, null, null, null ); + Assert.assertTrue( 1 >= cursor.getCount() ); + int indx = cursor.getColumnIndex( DBHelper.VALUE ); + if ( cursor.moveToNext() ) { + dflt = cursor.getString( indx ); + } + cursor.close(); + db.close(); + } + return dflt; + } + private static void copyGameDB( Context context, boolean toSDCard ) { String name = DBHelper.getDBName();