Fixes issue #301: Accounts with the same id can't be added
This commit is contained in:
parent
55627cdf29
commit
403ba40da6
|
@ -53,6 +53,7 @@ public class UpdateAccountInfoByIDAsyncTask extends AsyncTask<Void, Void, Void>
|
||||||
SharedPreferences sharedpreferences = this.contextReference.get().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = this.contextReference.get().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||||
Account account = new API(this.contextReference.get()).getAccount(userId);
|
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();
|
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);
|
boolean userExists = new AccountDAO(this.contextReference.get(), db).userExist(account);
|
||||||
if( userExists) {
|
if( userExists) {
|
||||||
|
|
|
@ -201,7 +201,7 @@ public class AccountDAO {
|
||||||
public boolean userExist(Account account)
|
public boolean userExist(Account account)
|
||||||
{
|
{
|
||||||
Cursor mCount= db.rawQuery("select count(*) from " + Sqlite.TABLE_USER_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();
|
mCount.moveToFirst();
|
||||||
int count = mCount.getInt(0);
|
int count = mCount.getInt(0);
|
||||||
mCount.close();
|
mCount.close();
|
||||||
|
|
Loading…
Reference in New Issue