public String loadUserNameFromDatabase(Context context) {
    TableInfoTable infoTable = new TableInfoTable();
    Cursor cursor =
        context
            .getContentResolver()
            .query(
                infoTable.getUri(),
                null,
                TableInfoTable.INFONAME + "=?",
                new String[] {"USERNAME"},
                null);
    if (cursor == null) return Constants.EMPTY_STRING;

    String ret = "";
    if (cursor.moveToFirst()) {
      ret = cursor.getString(cursor.getColumnIndex(TableInfoTable.INFOVALUE));
    }
    cursor.close();

    return ret;
  }
  /**
   * @param userName the userName to set
   * @param save save into database
   */
  public boolean setUserName(String userName, boolean save) {
    if (save) {
      TableInfoTable infoTable = new TableInfoTable();
      // update data into database
      ContentValues values = new ContentValues();
      values.put(TableInfoTable.INFOVALUE, userName);

      if (getContentResolver()
              .update(infoTable.getUri(), values, TableInfoTable.INFONAME + "='USERNAME'", null)
          != 1) {
        return false;
      }
    }
    // edit preferences
    Editor editPreferences = appPreferences.edit();
    editPreferences.putString(getString(PreferenceConstants.PREF_USER_NAME), userName);
    // commit
    //        editPreferences.commit();
    editPreferences.apply();
    // set the value
    MoneyManagerApplication.userName = userName;
    return true;
  }