*Hi I am new to android development and I am no where a professional as you’ll soon find out, anyways here’s the problem I am having:
I have two databases, namely
1->DatabaseClass and
2->TransactionDatabase
The database DatabaseClass has an entry for bank_name field and account_number(and others, but it doesn’t matter at this point). The TransactionDatabase also has a field for bank_name and account_number.
A spinner item in transaction side holds the list of all bank_names, these names are accessed from the DatabaseClass, by using a cursor.The items selected from the spinner are stored in the TransactionDatabase.
Now the user enters the account number for that selected bank in TransactionDatabase. If that bank’s account number matches the account number added in the database ‘DatabaseClass’, all the fields contained in that “particular” row which has that “particular” account number should be picked up from both the tables and should be inserted in different strings.
How can I compare the account_numbers ?, I collected the text contained in the edit text field named ‘account number’ in the transaction side.Also a bank name from spinner is selected. Now how can I get the account number from the ‘DatabaseClass’ corresponding to that bank name, for comparison?
I used this to set up the bank name in spinner :*
SimpleCursorAdapter myAdapter;
Cursor cursor = myDatabase.getData();
cursor.moveToFirst();
myAdapter = new SimpleCursorAdapter(AddTransaction.this,
R.layout.spinnerlayout, cursor,
new String[] { DatabaseClass.KEY_BANK_NAME_ID, },
new int[] { R.id.bankName });
mySpinner.setAdapter(myAdapter);
So far I am able to get the position of the item selected from spinner through the database DatabaseClass, please help me I am very confused.
int item = mySpinner.getSelectedItemPosition();
Cursor cursor = myDatabase.getData();
cursor.moveToPosition(item);
Your options:
and join the tables on the foreign_key. (Preferred)