safe Close Cursor - Android Database

Android examples for Database:Cursor

Description

safe Close Cursor

Demo Code


//package com.java2s;
import android.database.Cursor;

import android.util.Log;

public class Main {
    public static void safeClose(Cursor cursor) {
        if (cursor != null && !cursor.isClosed()) {
            try {
                cursor.close();//  ww  w  . ja  va2 s .  c o  m
            } catch (Exception e) {
                Log.e("WANXIANG", "Error closing "
                        + cursor.getClass().getSimpleName(), e);
            }
        }
    }
}

Related Tutorials