I want to insert multiple sms in “content://sms/” table. let’s say 500 sms.
my code is :
ContentValues [500] valuesarray = new ContentValues[];
for(int i=0;i<values.size();i++){
valuesarray[i] = values.get(i);
}
getContentResolver().bulkInsert(Uri.parse("content://sms/"), valuesarray);
It works, but it is extremely slow, and it makes no difference with insert() method. I serched on the net, and found methods like :
try {
database.beginTransaction();
for (ContentValues initialValues : allValues) {
values = initialValues == null ? new ContentValues() : new ContentValues(initialValues);
rowId = insertEvent(database, values);
if (rowId > 0)
rowsAdded++;
}
database.setTransactionSuccessful();
} catch (SQLException ex) {
} finally {
database.endTransaction();
}
But this is for personnal databases. How can I use a method like this with Android’s “content://sms/” provider?
You can’t, sorry.
(besides, that provider is not part of the Android SDK and may not exist on all devices, anyway, so you should not be using it)