0

I wonder how to implement this with 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..

edit: If this is insert method what Uri I should return?

Foenix
  • 991
  • 3
  • 10
  • 23

1 Answers1

0

Call execSql

@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;
}
Tarun
  • 13,727
  • 8
  • 42
  • 57