源于包android.database.sqlite.SQLiteDatabase
首先看一下继承和实现了那些基类和接口
SQLiteDatabase extends SQLiteClosable implements Closeable Closeable extends AutoCloseable
interface AutoCloseable //java. langvoid close() throws Exception;
Defines an interface for classes that can (or need to) be closed once they
* are not used any longer. Calling the {@code close} method releases resources
* that the object holds.
一旦不用回收释放资源,关闭资源
interface Closeable extends AutoCloseable //java.io
void close() throws IOException;
Closeable 是可以关闭的数据源或目标。调用 close 方法可释放对象保存的资源(如打开文件)
关闭此流并释放与此流关联的所有系统资源。如果已经关闭该流,则调用此方法无效。
abstract class SQLiteClosable implements Closeable // 抽象类
abstract void onAllReferencesReleased();//
void onAllReferencesReleasedFromContainer()
void acquireReference()
void releaseReference()
void releaseReferenceFromContainer()
public void close() {
releaseReference();//实现Closeable的方法
}
final class SQLiteDatabase
public static SQLiteDatabase openDatabase(String path, CursorFactory factory, int flags) {
return openDatabase(path, factory, flags, null);
}
public static SQLiteDatabase openDatabase(String path, CursorFactory factory, int flags,
DatabaseErrorHandler errorHandler) {//路径 cuesor构造器,传null使用默认构造器
SQLiteDatabase db = new SQLiteDatabase(path, flags, factory, errorHandler);
db.open();
return db;
}
public static boolean deleteDatabase(File file) //删除数据库
public void reopenReadWrite()
public Cursor query(boolean distinct, String table, String[] columns,
String selection, String[] selectionArgs, String groupBy,
String having, String orderBy, String limit) {
return queryWithFactory(null, distinct, table, columns, selection, selectionArgs,
groupBy, having, orderBy, limit, null);
}