大家好,我正在尝试在 android 中使用自定义 sqlite 查询。
我遇到了以下问题:
1- 我的主键由多列组成。我如何将数据放在 android 中的 Db sqlite 中?做
ContentValues initialValues = new ContentValues();
这个过程会起作用吗?
2- 自定义查询
String queryString = "SELECT MAX(accountId) FROM MAAccounts WHERE userId = ? AND accountType = ?";
我想传递两个参数
String userId, AccountType accountType
注意userId为string类型,accoutType为int或AccountType。
请告诉我这在 sqlite android 中是否可以传递自定义查询和参数?如果是,那又如何?
3- 另外,在 Iphone 中我们使用 FMD Database
库,是否有任何库可以像 Iphone 一样在 android 中使用?
最佳答案
自定义查询使用方法:
db.rawQuery("MAX(accountId) FROM MAAccounts WHERE userId = ? AND accountType = ?", new String[]{value1,value2});
这里的value1和value2是要传递的值。
关于java - Android sqlite 中的自定义查询和多列上的主键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9155398/