Im new to android I'm using content provider in my application, In my application I want to join two tables but I don't know how to do it, please help me find out solution
my tables:
CREATE TABLE Bank_customers (customer_id varchar PRIMARY KEY ,
customer_name varchar,
customer_date_of_birth date,
address varchar,
mobile integer,
email varchar);
CREATE TABLE Bank_accounts (account_number integer(11) PRIMARY KEY,
customer_id varchar ,
account_type text,
account_open_date date,
account_balance real,FOREIGN KEY(customer_id) REFERENCES Bank_customers(customer_id));
my query: **SELECT mobile,Bank_accounts.customer_id from Bank_accounts,Bank_customers WHERE Bank_customers.customer_id = Bank_accounts.customer_id and Bank_accounts.account_number = 13323;**
How I can implement above query using content provider class "query method"
This is easy to do. You need to think of the join as an abstract table (sorry, code is in Java...)
First, create a new
content:
URL and use aURIMatcher
to parse it:Now, in your query method, delegate queries with the matching URL to a separate method:
Now, all you have to do is query the join, in the new method:
You may want to use the QueryBuilder's
ColumnMap
to map abstract aliases onto column names.