我的代码是:
public static Uri addCall(CallerInfo ci, Context context, String number,boolean isPrivateNumber, int callType, long start, int duration) {
final ContentResolver resolver = context.getContentResolver();
if (TextUtils.isEmpty(number)) {
if (isPrivateNumber) {
number = CallerInfo.PRIVATE_NUMBER;
} else {
number = CallerInfo.UNKNOWN_NUMBER;
}
}
ContentValues values = new ContentValues(5);
if (number.contains("&"))
number = number.substring(0,number.indexOf("&"));
values.put(Calls.NUMBER, number);
values.put(Calls.TYPE, Integer.valueOf(callType));
values.put(Calls.DATE, Long.valueOf(start));
values.put(Calls.DURATION, Long.valueOf(duration));
values.put(Calls.NEW, Integer.valueOf(1));
if (ci != null) {
values.put(Calls.CACHED_NAME, ci.name);
values.put(Calls.CACHED_NUMBER_TYPE, ci.numberType);
values.put(Calls.CACHED_NUMBER_LABEL, ci.numberLabel);
}
if ((ci != null) && (ci.person_id > 0)) {
People.markAsContacted(resolver, ci.person_id);
}
Uri result = resolver.insert(Calls.CONTENT_URI, values);
if (result != null) { // send info about call to call meter
final Intent intent = new Intent(ACTION_CM_SIP);
intent.putExtra(EXTRA_SIP_URI, result.toString());
// TODO: add provider
// intent.putExtra(EXTRA_SIP_PROVIDER, null);
context.sendBroadcast(intent);
}
return result;
}
但是会抛出这样的异常:
07-11 14:36:36.515: WARN/SQLiteCompiledSql(3308): Releasing statement in a finalizer. Please ensure that you explicitly call close() on your cursor: INSERT INTO logs ('_id', 'number', 'address', 'date', 'duration', 'type', 'new', 'name', 'name_rever
07-11 14:36:36.515: WARN/SQLiteCompiledSql(3308): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
07-11 14:36:36.515: WARN/SQLiteCompiledSql(3308): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:62)
07-11 14:36:36.515: WARN/SQLiteCompiledSql(3308): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:100)
07-11 14:36:36.515: WARN/SQLiteCompiledSql(3308): at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:36)
07-11 14:36:36.515: WARN/SQLiteCompiledSql(3308): at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1254)
07-11 14:36:36.515: WARN/SQLiteCompiledSql(3308): at android.database.DatabaseUtils$InsertHelper.getStatement(DatabaseUtils.java:858)
07-11 14:36:36.515: WARN/SQLiteCompiledSql(3308): at android.database.DatabaseUtils$InsertHelper.insertInternal(DatabaseUtils.java:878)
07-11 14:36:36.515: WARN/SQLiteCompiledSql(3308): at android.database.DatabaseUtils$InsertHelper.insert(DatabaseUtils.java:1011)
07-11 14:36:36.515: WARN/SQLiteCompiledSql(3308): at com.android.providers.contacts.CallLogProvider.insert(CallLogProvider.java:240)
07-11 14:36:36.515: WARN/SQLiteCompiledSql(3308): at android.content.ContentProvider$Transport.insert(ContentProvider.java:174)
07-11 14:36:36.515: WARN/SQLiteCompiledSql(3308): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:146)
07-11 14:36:36.515: WARN/SQLiteCompiledSql(3308): at android.os.Binder.execTransact(Binder.java:288)
07-11 14:36:36.515: WARN/SQLiteCompiledSql(3308): at dalvik.system.NativeStart.run(Native Method)
请提供解决方案来解决这个问题