Fixes issue #301: Accounts with the same id can't be added

This commit is contained in:
stom79 2018-02-09 13:37:10 +01:00
parent 55627cdf29
commit 403ba40da6
2 changed files with 2 additions and 1 deletions

View File

@ -53,6 +53,7 @@ public class UpdateAccountInfoByIDAsyncTask extends AsyncTask<Void, Void, Void>
SharedPreferences sharedpreferences = this.contextReference.get().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
Account account = new API(this.contextReference.get()).getAccount(userId);
account.setInstance(Helper.getLiveInstance(contextReference.get()));
SQLiteDatabase db = Sqlite.getInstance(this.contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
boolean userExists = new AccountDAO(this.contextReference.get(), db).userExist(account);
if( userExists) {

View File

@ -201,7 +201,7 @@ public class AccountDAO {
public boolean userExist(Account account)
{
Cursor mCount= db.rawQuery("select count(*) from " + Sqlite.TABLE_USER_ACCOUNT
+ " where " + Sqlite.COL_USER_ID + " = '" + account.getId() + "' AND " + Sqlite.COL_USERNAME + " = '" + account.getUsername()+ "'", null);
+ " where " + Sqlite.COL_ACCT + " = '" + account.getAcct() + "' AND " + Sqlite.COL_INSTANCE + " = '" + account.getInstance()+ "'", null);
mCount.moveToFirst();
int count = mCount.getInt(0);
mCount.close();