[英]Insert several rows from 1st table to the 2nd with ContentProvider
I wonder how to implement this with ContentProvider? 我想知道如何用ContentProvider来实现吗? I insert several rows from table to another with single select statment:
我使用单个选择语句将表中的几行插入到另一行:
insert into table1 (field1, field2,...)
select field1, field2... from table2 where ...
If I should use insert method, I cannot get this several new id.. 如果我应该使用插入方法,则无法获得这几个新的ID。
edit: If this is insert method what Uri I should return? 编辑:如果这是插入方法我应该返回什么Uri ?
@Override
public Uri insert(Uri uri, ContentValues initialValues) {
switch (sUriMatcher.match(uri)){
case URI_1:
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
db.execSql("insert into table1 (field1, field2,...)
select field1, field2... from table2 where ...");
return uri;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.