Muhammad Umar
Muhammad Umar

Reputation: 11782

Custom queries in Android sqlite and Primary key on multiple colums

Hi guys i am trying to use a custom sqlite queries in android.

i am experiencing following problems :

1- My primary key consists of multiple columns. How can i place data in Db sqlite in android? Does

ContentValues initialValues = new ContentValues();

This process will work?

2- Custom queries

String queryString = "SELECT MAX(accountId) FROM MAAccounts WHERE userId = ? AND accountType = ?";

i want to pass two parameters

String userId, AccountType accountType

Note that userId is string type and accoutType is int or AccountType.

Please tell me if this is possible in sqlite android to pass custom queries and arguments or not? If so then how?

3- Also, in Iphone we use FMD Database library , is there any library which we can use in android just like Iphone one?

Upvotes: 1

Views: 1120

Answers (1)

jeet
jeet

Reputation: 29199

For custom query use method:

db.rawQuery("MAX(accountId) FROM MAAccounts WHERE userId = ? AND accountType = ?", new String[]{value1,value2});

here value1 and value2 are values to be passed.

Upvotes: 2

Related Questions