public ManagePreferences(Context _context, String _contactId) { contactId = _contactId; context = _context; useDatabase = false; if (Log.DEBUG) Log.v("contactId = " + contactId); long contactIdLong; try { contactIdLong = Long.parseLong(contactId); } catch (NumberFormatException e) { contactIdLong = 0; } if (contactIdLong > 0) { mDbAdapter = new SmsPopupDbAdapter(context); try { mDbAdapter.open(true); // Open database read-only contactCursor = mDbAdapter.fetchContactSettings(contactIdLong); if (contactCursor != null) { if (Log.DEBUG) Log.v("Contact found - using database"); useDatabase = true; } mDbAdapter.close(); } catch (SQLException e) { if (Log.DEBUG) Log.v("Error opening or creating database"); useDatabase = false; } } else { if (Log.DEBUG) Log.v("Contact NOT found - using prefs"); } mPrefs = PreferenceManager.getDefaultSharedPreferences(context); }