|
|
@ -11,86 +11,159 @@ import android.database.Cursor;
|
|
|
|
import android.database.DatabaseErrorHandler;
|
|
|
|
import android.database.DatabaseErrorHandler;
|
|
|
|
import android.os.CancellationSignal;
|
|
|
|
import android.os.CancellationSignal;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public final class SQLiteDatabase {
|
|
|
|
public final class SQLiteDatabase {
|
|
|
|
|
|
|
|
|
|
|
|
private SQLiteDatabase(String path, int openFlags, CursorFactory cursorFactory,
|
|
|
|
private SQLiteDatabase(
|
|
|
|
DatabaseErrorHandler errorHandler) {
|
|
|
|
String path, int openFlags, CursorFactory cursorFactory, DatabaseErrorHandler errorHandler) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Cursor query(
|
|
|
|
|
|
|
|
boolean distinct,
|
|
|
|
public Cursor query(boolean distinct, String table, String[] columns,
|
|
|
|
String table,
|
|
|
|
String selection, String[] selectionArgs, String groupBy,
|
|
|
|
String[] columns,
|
|
|
|
String having, String orderBy, String limit) {
|
|
|
|
String selection,
|
|
|
|
return queryWithFactory(null, distinct, table, columns, selection, selectionArgs,
|
|
|
|
String[] selectionArgs,
|
|
|
|
groupBy, having, orderBy, limit, null);
|
|
|
|
String groupBy,
|
|
|
|
|
|
|
|
String having,
|
|
|
|
|
|
|
|
String orderBy,
|
|
|
|
|
|
|
|
String limit) {
|
|
|
|
|
|
|
|
return queryWithFactory(
|
|
|
|
|
|
|
|
null,
|
|
|
|
|
|
|
|
distinct,
|
|
|
|
|
|
|
|
table,
|
|
|
|
|
|
|
|
columns,
|
|
|
|
|
|
|
|
selection,
|
|
|
|
|
|
|
|
selectionArgs,
|
|
|
|
|
|
|
|
groupBy,
|
|
|
|
|
|
|
|
having,
|
|
|
|
|
|
|
|
orderBy,
|
|
|
|
|
|
|
|
limit,
|
|
|
|
|
|
|
|
null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Cursor query(
|
|
|
|
public Cursor query(boolean distinct, String table, String[] columns,
|
|
|
|
boolean distinct,
|
|
|
|
String selection, String[] selectionArgs, String groupBy,
|
|
|
|
String table,
|
|
|
|
String having, String orderBy, String limit, CancellationSignal cancellationSignal) {
|
|
|
|
String[] columns,
|
|
|
|
return queryWithFactory(null, distinct, table, columns, selection, selectionArgs,
|
|
|
|
String selection,
|
|
|
|
groupBy, having, orderBy, limit, cancellationSignal);
|
|
|
|
String[] selectionArgs,
|
|
|
|
|
|
|
|
String groupBy,
|
|
|
|
|
|
|
|
String having,
|
|
|
|
|
|
|
|
String orderBy,
|
|
|
|
|
|
|
|
String limit,
|
|
|
|
|
|
|
|
CancellationSignal cancellationSignal) {
|
|
|
|
|
|
|
|
return queryWithFactory(
|
|
|
|
|
|
|
|
null,
|
|
|
|
|
|
|
|
distinct,
|
|
|
|
|
|
|
|
table,
|
|
|
|
|
|
|
|
columns,
|
|
|
|
|
|
|
|
selection,
|
|
|
|
|
|
|
|
selectionArgs,
|
|
|
|
|
|
|
|
groupBy,
|
|
|
|
|
|
|
|
having,
|
|
|
|
|
|
|
|
orderBy,
|
|
|
|
|
|
|
|
limit,
|
|
|
|
|
|
|
|
cancellationSignal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Cursor queryWithFactory(
|
|
|
|
public Cursor queryWithFactory(CursorFactory cursorFactory,
|
|
|
|
CursorFactory cursorFactory,
|
|
|
|
boolean distinct, String table, String[] columns,
|
|
|
|
boolean distinct,
|
|
|
|
String selection, String[] selectionArgs, String groupBy,
|
|
|
|
String table,
|
|
|
|
String having, String orderBy, String limit) {
|
|
|
|
String[] columns,
|
|
|
|
return queryWithFactory(cursorFactory, distinct, table, columns, selection,
|
|
|
|
String selection,
|
|
|
|
selectionArgs, groupBy, having, orderBy, limit, null);
|
|
|
|
String[] selectionArgs,
|
|
|
|
|
|
|
|
String groupBy,
|
|
|
|
|
|
|
|
String having,
|
|
|
|
|
|
|
|
String orderBy,
|
|
|
|
|
|
|
|
String limit) {
|
|
|
|
|
|
|
|
return queryWithFactory(
|
|
|
|
|
|
|
|
cursorFactory,
|
|
|
|
|
|
|
|
distinct,
|
|
|
|
|
|
|
|
table,
|
|
|
|
|
|
|
|
columns,
|
|
|
|
|
|
|
|
selection,
|
|
|
|
|
|
|
|
selectionArgs,
|
|
|
|
|
|
|
|
groupBy,
|
|
|
|
|
|
|
|
having,
|
|
|
|
|
|
|
|
orderBy,
|
|
|
|
|
|
|
|
limit,
|
|
|
|
|
|
|
|
null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Cursor queryWithFactory(
|
|
|
|
public Cursor queryWithFactory(CursorFactory cursorFactory,
|
|
|
|
CursorFactory cursorFactory,
|
|
|
|
boolean distinct, String table, String[] columns,
|
|
|
|
boolean distinct,
|
|
|
|
String selection, String[] selectionArgs, String groupBy,
|
|
|
|
String table,
|
|
|
|
String having, String orderBy, String limit, CancellationSignal cancellationSignal) {
|
|
|
|
String[] columns,
|
|
|
|
|
|
|
|
String selection,
|
|
|
|
|
|
|
|
String[] selectionArgs,
|
|
|
|
|
|
|
|
String groupBy,
|
|
|
|
|
|
|
|
String having,
|
|
|
|
|
|
|
|
String orderBy,
|
|
|
|
|
|
|
|
String limit,
|
|
|
|
|
|
|
|
CancellationSignal cancellationSignal) {
|
|
|
|
return rawQueryWithFactory(cursorFactory, null, selectionArgs, table, cancellationSignal);
|
|
|
|
return rawQueryWithFactory(cursorFactory, null, selectionArgs, table, cancellationSignal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Cursor query(String table, String[] columns, String selection,
|
|
|
|
public Cursor query(
|
|
|
|
String[] selectionArgs, String groupBy, String having,
|
|
|
|
String table,
|
|
|
|
|
|
|
|
String[] columns,
|
|
|
|
|
|
|
|
String selection,
|
|
|
|
|
|
|
|
String[] selectionArgs,
|
|
|
|
|
|
|
|
String groupBy,
|
|
|
|
|
|
|
|
String having,
|
|
|
|
String orderBy) {
|
|
|
|
String orderBy) {
|
|
|
|
|
|
|
|
|
|
|
|
return query(false, table, columns, selection, selectionArgs, groupBy,
|
|
|
|
return query(
|
|
|
|
having, orderBy, null /* limit */);
|
|
|
|
false,
|
|
|
|
|
|
|
|
table,
|
|
|
|
|
|
|
|
columns,
|
|
|
|
|
|
|
|
selection,
|
|
|
|
|
|
|
|
selectionArgs,
|
|
|
|
|
|
|
|
groupBy,
|
|
|
|
|
|
|
|
having,
|
|
|
|
|
|
|
|
orderBy,
|
|
|
|
|
|
|
|
null /* limit */);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Cursor query(String table, String[] columns, String selection,
|
|
|
|
public Cursor query(
|
|
|
|
String[] selectionArgs, String groupBy, String having,
|
|
|
|
String table,
|
|
|
|
String orderBy, String limit) {
|
|
|
|
String[] columns,
|
|
|
|
|
|
|
|
String selection,
|
|
|
|
return query(false, table, columns, selection, selectionArgs, groupBy,
|
|
|
|
String[] selectionArgs,
|
|
|
|
having, orderBy, limit);
|
|
|
|
String groupBy,
|
|
|
|
|
|
|
|
String having,
|
|
|
|
|
|
|
|
String orderBy,
|
|
|
|
|
|
|
|
String limit) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return query(false, table, columns, selection, selectionArgs, groupBy, having, orderBy, limit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Cursor rawQuery(String sql, String[] selectionArgs) {
|
|
|
|
public Cursor rawQuery(String sql, String[] selectionArgs) {
|
|
|
|
return rawQueryWithFactory(null, sql, selectionArgs, null, null);
|
|
|
|
return rawQueryWithFactory(null, sql, selectionArgs, null, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Cursor rawQuery(String sql, String[] selectionArgs,
|
|
|
|
public Cursor rawQuery(
|
|
|
|
CancellationSignal cancellationSignal) {
|
|
|
|
String sql, String[] selectionArgs, CancellationSignal cancellationSignal) {
|
|
|
|
return rawQueryWithFactory(null, sql, selectionArgs, null, cancellationSignal);
|
|
|
|
return rawQueryWithFactory(null, sql, selectionArgs, null, cancellationSignal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Cursor rawQueryWithFactory(
|
|
|
|
public Cursor rawQueryWithFactory(
|
|
|
|
CursorFactory cursorFactory, String sql, String[] selectionArgs,
|
|
|
|
CursorFactory cursorFactory, String sql, String[] selectionArgs, String editTable) {
|
|
|
|
String editTable) {
|
|
|
|
|
|
|
|
return rawQueryWithFactory(cursorFactory, sql, selectionArgs, editTable, null);
|
|
|
|
return rawQueryWithFactory(cursorFactory, sql, selectionArgs, editTable, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Cursor rawQueryWithFactory(
|
|
|
|
public Cursor rawQueryWithFactory(
|
|
|
|
CursorFactory cursorFactory, String sql, String[] selectionArgs,
|
|
|
|
CursorFactory cursorFactory,
|
|
|
|
String editTable, CancellationSignal cancellationSignal) {
|
|
|
|
String sql,
|
|
|
|
|
|
|
|
String[] selectionArgs,
|
|
|
|
|
|
|
|
String editTable,
|
|
|
|
|
|
|
|
CancellationSignal cancellationSignal) {
|
|
|
|
return new SQLiteCursor(null, editTable, null);
|
|
|
|
return new SQLiteCursor(null, editTable, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public interface CursorFactory {
|
|
|
|
public interface CursorFactory {
|
|
|
|
public Cursor newCursor(SQLiteDatabase db,
|
|
|
|
public Cursor newCursor(
|
|
|
|
SQLiteCursorDriver masterQuery, String editTable,
|
|
|
|
SQLiteDatabase db, SQLiteCursorDriver masterQuery, String editTable, SQLiteQuery query);
|
|
|
|
SQLiteQuery query);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|