赞
踩
我有一个活动,通过在ContentResolver上执行applyBatch()命令在Android设备上插入大量联系人。我在很多Android设备上运行这个应用程序,除了Galaxy S2 I9100手机(Android 4.0版本)之外它似乎工作正常,经过多次插入后,我对之后执行的每个命令都得到以下异常:
E/CursorWindow( 5727): Could not allocate CursorWindow '/data/data/com.android.providers.contacts/databases/contacts2.db' of size 2097152 due to error -12.
E/JavaBinder( 5727): *** Uncaught remote exception! (Exceptions are not yet supported across processes.)
E/JavaBinder( 5727): android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. # Open Cursors=819 (# cursors opened by pid 5701=819)
E/JavaBinder( 5727): at android.database.CursorWindow.(CursorWindow.java:104)
E/JavaBinder( 5727): at android.database.AbstractWindowedCursor.clearOrCreateWindow
(AbstractWindowedCursor.java:198)
E/JavaBinder( 5727): at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:162)
E/JavaBinder( 5727): at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:156)
E/JavaBinder( 5727): at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:161)
E/JavaBinder( 5727): at android.database.AbstractCursor.moveToNext(AbstractCursor.java:209)
E/JavaBinder( 5727): at com.android.providers.contacts.ContactsProvider2.findGroupByRawContactId(ContactsProvider2.java:3738)
E/JavaBinder( 5727): at com.android.providers.contacts.ContactsProvider2.addAutoAddMembership(ContactsProvider2.java:3725)
E/JavaBinder( 5727): at com.android.providers.contacts.ContactsProvider2.insertRawContact(ContactsProvider2.java:3713)
E/JavaBinder( 5727): at com.android.providers.contacts.ContactsProvider2.insertInTransaction(ContactsProvider2.java:3360)
E/JavaBinder( 5727): at com.android.providers.contacts.AbstractContactsProvider.insert(AbstractContactsProvider.java:108)
E/JavaBinder( 5727): at com.android.providers.contacts.ContactsProvider2.insert(ContactsProvider2.java:2605)
E/JavaBinder( 5727): at android.content.ContentProviderOperation.apply(ContentProviderOperation.java:214)
E/JavaBinder( 5727): at com.android.providers.contacts.AbstractContactsProvider.applyBatch(AbstractContactsProvider.java:203)
E/JavaBinder( 5727): at com.android.providers.contacts.ContactsProvider2.applyBatch(ContactsProvider2.java:2755)
E/JavaBinder( 5727): at android.content.ContentProvider$Transport.applyBatch(ContentProvider.java:208)
E/JavaBinder( 5727): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:179)
E/JavaBinder( 5727): at android.os.Binder.execTransact(Binder.java:338)
E/JavaBinder( 5727): at dalvik.system.NativeStart.run(Native Method)
异常中提到的PID是运行android.process.acore包。
实际上,当我在执行初始插入时监视进程时,我看到此PID正在生成日志,提到“游标在关闭之前已完成”
有没有人对这种奇怪的行为有所了解?
下面是执行插入的代码:
ArrayList ops = new ArrayList();
ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
.withValue(RawContacts.ACCOUNT_TYPE, "")
.withValue(RawContacts.ACCOUNT_NAME, "").build());
ops.addAll(vCardUtility.readVCard(vCard));
Log.w(TAG, "TRYING TO EXECUTE " + ops.size() + " OPERATIONS");
r = cr.applyBatch(ContactsContract.AUTHORITY, ops);
readVcard只是创建ContentProviderOperation对象列表以插入联系人详细信息。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。