Java 类android.database.sqlite.SQLiteCursor 实例源码
项目:AvI
文件:SQLiteAndroidDatabase.java
private void bindPreHoneycomb(JSONObject row, String key, Cursor cursor, int i) throws JSONException {
// Since cursor.getType() is not available pre-honeycomb, this is
// a workaround so we don't have to bind everything as a string
// Details here: http://stackoverflow.com/q/11658239
SQLiteCursor sqLiteCursor = (SQLiteCursor) cursor;
CursorWindow cursorWindow = sqLiteCursor.getWindow();
int pos = cursor.getPosition();
if (cursorWindow.isNull(pos, i)) {
row.put(key, JSONObject.NULL);
} else if (cursorWindow.isLong(pos, i)) {
row.put(key, cursor.getLong(i));
} else if (cursorWindow.isFloat(pos, i)) {
row.put(key, cursor.getDouble(i));
/* ** Read BLOB as Base-64 DISABLED in this branch:
} else if (cursorWindow.isBlob(pos, i)) {
row.put(key, new String(Base64.encode(cursor.getBlob(i), Base64.DEFAULT)));
// ** Read BLOB as Base-64 DISABLED to HERE. */
} else { // string
row.put(key, cursor.getString(i));
}
}
项目:geopackage-android
文件:GeoPackageCursorFactory.java
/**
* {@inheritDoc}
*/
@Override
public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver driver,
String editTable, SQLiteQuery query) {
// Create a standard cursor
Cursor cursor = new SQLiteCursor(driver, editTable, query);
// Check if there is an edit table
if (editTable != null) {
// Check if the table has a cursor wrapper
GeoPackageCursorWrapper cursorWrapper = tableCursors.get(editTable);
if (cursorWrapper != null) {
cursor = cursorWrapper.wrapCursor(cursor);
}
}
return cursor;
}
项目:FullRobolectricTestSample
文件:ActivityTest.java
@Test
public void startAndStopManagingCursorTracksCursors() throws Exception {
TestActivity activity = new TestActivity();
ShadowActivity shadow = shadowOf(activity);
assertThat(shadow.getManagedCursors()).isNotNull();
assertThat(shadow.getManagedCursors().size()).isEqualTo(0);
Cursor c = Robolectric.newInstanceOf(SQLiteCursor.class);
activity.startManagingCursor(c);
assertThat(shadow.getManagedCursors()).isNotNull();
assertThat(shadow.getManagedCursors().size()).isEqualTo(1);
assertThat(shadow.getManagedCursors().get(0)).isSameAs(c);
activity.stopManagingCursor(c);
assertThat(shadow.getManagedCursors()).isNotNull();
assertThat(shadow.getManagedCursors().size()).isEqualTo(0);
}
项目:android_dbinspector
文件:DatabaseHelper.java
/**
* Compat method so we can get type of column on API < 11.
* Source: http://stackoverflow.com/a/20685546/2643666
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static int getColumnType(Cursor cursor, int col) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
SQLiteCursor sqLiteCursor = (SQLiteCursor) cursor;
CursorWindow cursorWindow = sqLiteCursor.getWindow();
int pos = cursor.getPosition();
int type = -1;
if (cursorWindow.isNull(pos, col)) {
type = FIELD_TYPE_NULL;
} else if (cursorWindow.isLong(pos, col)) {
type = FIELD_TYPE_INTEGER;
} else if (cursorWindow.isFloat(pos, col)) {
type = FIELD_TYPE_FLOAT;
} else if (cursorWindow.isString(pos, col)) {
type = FIELD_TYPE_STRING;
} else if (cursorWindow.isBlob(pos, col)) {
type = FIELD_TYPE_BLOB;
}
return type;
} else {
return cursor.getType(col);
}
}
项目:juahya
文件:DataProvider.java
/**
* �����ֶ��Ƿ����
* @param colName
* @return
*/
public boolean columnIsExist(String colName, String tableName){
boolean isExist = false;
try{
String sql = "select " + colName + " from " + tableName;
SQLiteCursor cursor = this.query(sql);
while(cursor.moveToNext()){
isExist = true;
break;
}
cursor.close();
}catch(Exception ex){
// ex.printStackTrace();
}
return isExist;
}
项目:juahya
文件:DataProvider.java
/**
* ����ij���Ƿ����
* @param tableName
* @return
*/
public boolean tableIsExist(String tableName){
boolean isExist = false;
if(tableName == null){
return false;
}
try{
String sql = "select count(*) from Sqlite_master where type ='table' and name ='"+tableName.trim()+"' ";
SQLiteCursor cursor = this.query(sql);
while(cursor.moveToNext()){
int count = cursor.getInt(0);
if(count > 0){
isExist = true;
}
}
cursor.close();
}catch(Exception ex){
ex.printStackTrace();
}
return isExist;
}
项目:whassup
文件:Whassup.java
public SQLiteDatabase openDatabase(final File dbFile) {
return SQLiteDatabase.openDatabase(dbFile.getAbsolutePath(), new SQLiteDatabase.CursorFactory() {
@Override
@SuppressWarnings("deprecation")
public Cursor newCursor(final SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query) {
return new SQLiteCursor(db, driver, editTable, query) {
@Override
public void close() {
Log.d(TAG, "closing cursor");
super.close();
db.close();
if (!dbFile.delete()) {
Log.w(TAG, "could not delete database " + dbFile);
}
}
};
}
}, SQLiteDatabase.OPEN_READWRITE);
}
项目:dmassist
文件:LoadEntity.java
private Collection<Integer> getCheckedIds() {
Collection<Integer> checkedIds = new ArrayList<Integer>();
for (int i = 0; i < getListView().getCount(); ++i) {
View view = getListView().getChildAt(i);
if (view == null) {
//AndroidUtils.displayInfoBox(this, "Hmm...", "view " + i + " is null");
break;
}
}
SparseBooleanArray isChecked = getListView().getCheckedItemPositions();
for (int i = 0; i < adapter.getCount(); ++i) {
if (isChecked.get(i)) {
final SQLiteCursor item = (SQLiteCursor)adapter.getItem(i);
int id = item.getInt(0);
checkedIds.add(id);
}
}
return checkedIds;
}
项目:justintrain-client-android
文件:FrameworkSQLiteDatabase.java
@Override
public Cursor query(final SupportSQLiteQuery supportQuery) {
return mDelegate.rawQueryWithFactory((db, masterQuery, editTable, query) -> {
supportQuery.bindTo(new FrameworkSQLiteProgram(query));
return new SQLiteCursor(masterQuery, editTable, query);
}, supportQuery.getSql(), EMPTY_STRING_ARRAY, null);
}
项目:justintrain-client-android
文件:FrameworkSQLiteDatabase.java
@Override
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
public Cursor query(final SupportSQLiteQuery supportQuery,
CancellationSignal cancellationSignal) {
return mDelegate.rawQueryWithFactory((db, masterQuery, editTable, query) -> {
supportQuery.bindTo(new FrameworkSQLiteProgram(query));
return new SQLiteCursor(masterQuery, editTable, query);
}, supportQuery.getSql(), EMPTY_STRING_ARRAY, null, cancellationSignal);
}
项目:OftenPorter
文件:TypeUtil.java
private static int getType(Cursor cursor, int columnIndex) throws Exception
{
if (Build.VERSION.SDK_INT >= 11)
{
return cursor.getType(columnIndex);
}
SQLiteCursor sqLiteCursor = (SQLiteCursor) cursor;
CursorWindow cursorWindow = sqLiteCursor.getWindow();
int pos = cursor.getPosition();
int type = -1;
if (cursorWindow.isNull(pos, columnIndex))
{
type = Cursor.FIELD_TYPE_NULL;
} else if (cursorWindow.isLong(pos, columnIndex))
{
type = Cursor.FIELD_TYPE_INTEGER;
} else if (cursorWindow.isFloat(pos, columnIndex))
{
type = Cursor.FIELD_TYPE_FLOAT;
} else if (cursorWindow.isString(pos, columnIndex))
{
type = Cursor.FIELD_TYPE_STRING;
} else if (cursorWindow.isBlob(pos, columnIndex))
{
type = Cursor.FIELD_TYPE_BLOB;
}
return type;
}
项目:sqliteAsset
文件:FrameworkSQLiteDatabase.java
@Override
public Cursor query(final SupportSQLiteQuery supportQuery) {
return mDelegate.rawQueryWithFactory((db, masterQuery, editTable, query) -> {
supportQuery.bindTo(new FrameworkSQLiteProgram(query));
return new SQLiteCursor(masterQuery, editTable, query);
}, supportQuery.getSql(), EMPTY_STRING_ARRAY, null);
}
项目:sqliteAsset
文件:FrameworkSQLiteDatabase.java
@Override
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
public Cursor query(final SupportSQLiteQuery supportQuery,
CancellationSignal cancellationSignal) {
return mDelegate.rawQueryWithFactory((db, masterQuery, editTable, query) -> {
supportQuery.bindTo(new FrameworkSQLiteProgram(query));
return new SQLiteCursor(masterQuery, editTable, query);
}, supportQuery.getSql(), EMPTY_STRING_ARRAY, null, cancellationSignal);
}
项目:beige-software
文件:CursorFactory.java
@Override
public final Cursor newCursor(final SQLiteDatabase pDb,
final SQLiteCursorDriver pMasterQuery, final String pEditTable,
final SQLiteQuery pQuery) {
return new SQLiteCursor(pDb, pMasterQuery, pEditTable, pQuery) {
@Override
public boolean requery() {
setSelectionArguments(new String[] {"2"});
return super.requery();
}
};
}
项目:alchemy
文件:AndroidQuery.java
@Override
public SQLiteIterator select() {
mDb.acquireReference();
try {
final SQLiteCursorDriver driver = SQLiteCompat.newDriver(mDb, mSql);
return new CursorIterator(new SQLiteCursor(driver, null, mQuery));
} finally {
mDb.releaseReference();
}
}
项目:forsuredbandroid
文件:FSCursorFactory.java
@Override
public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery, String editTable, SQLiteQuery query) {
if (FSDBHelper.inst().inDebugMode()) {
Log.d("forsuredb", "Running query: " + masterQuery.toString());
}
return new FSCursor(new SQLiteCursor(masterQuery, editTable, query));
}
项目:simpledb
文件:CloseCursorFactory.java
@Override
public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery, String editTable, SQLiteQuery query) {
/**
* {@link SQLiteDatabase} and {@link android.database.sqlite.SQLiteDirectCursorDriver}
*/
return new AutoCloseCursor(new SQLiteCursor(masterQuery, editTable, query));
}
项目:simpledb
文件:AutoCloseCursor.java
@Override
protected void finalize() throws Throwable {
try {
if (!getWrappedCursor().isClosed()) {
showLeakInfo((SQLiteCursor) getWrappedCursor());
close();
}
} finally {
super.finalize();
}
}
项目:simpledb
文件:AutoCloseCursor.java
private void showLeakInfo(SQLiteCursor cursor) {
Log.e("", "### ==========> Cursor泄露了, Cursor中的字段为 : ");
String[] columnNames = cursor.getColumnNames();
for (int i = 0; i < columnNames.length; i++) {
Log.e("", "### column -> " + columnNames[i]);
}
Log.e("", "### ==========>Cursor 泄露 !!!!!! END ");
}
项目:hill-lists
文件:HillsDatabaseHelper.java
public static synchronized HillsDatabaseHelper getInstance(Context context) {
if (sInstance == null) {
sInstance = new HillsDatabaseHelper(context.getApplicationContext(), DATABASE_NAME
, (sqLiteDatabase, sqLiteCursorDriver, s, sqLiteQuery) -> {
Log.d("SQL", sqLiteQuery.toString());
return new SQLiteCursor(sqLiteDatabase, sqLiteCursorDriver, s, sqLiteQuery);
}, DATABASE_VERSION);
}
return sInstance;
}
项目:hill-lists
文件:TestHelper.java
public static synchronized TestHelper getInstance(Context context) {
if (sInstance == null) {
sInstance = new TestHelper(context.getApplicationContext(), DATABASE_NAME
, (sqLiteDatabase, sqLiteCursorDriver, s, sqLiteQuery) -> {
Log.d("SQL", sqLiteQuery.toString());
return new SQLiteCursor(sqLiteDatabase, sqLiteCursorDriver, s, sqLiteQuery);
}, DATABASE_VERSION);
}
return sInstance;
}
项目:ThingSpeak-client-android
文件:SuggestionSearchView.java
@Override
public boolean onSuggestionClick(int position) {
SQLiteCursor cursor = (SQLiteCursor) getSuggestionsAdapter().getItem(position);
int indexColumnSuggestion = cursor.getColumnIndex(SuggestionsDatabase.FIELD_SUGGESTION);
setQuery(cursor.getString(indexColumnSuggestion), false);
return true;
}
项目:QuantumFlux
文件:QuantumFluxCursorFactory.java
@Override
public Cursor newCursor(SQLiteDatabase sqLiteDatabase, SQLiteCursorDriver sqLiteCursorDriver, String tableName, SQLiteQuery sqLiteQuery) {
if (isDebugEnabled) {
QuantumFluxLog.d(sqLiteQuery.toString());
}
return new SQLiteCursor(sqLiteCursorDriver, tableName, sqLiteQuery);
}
项目:AndroidLife
文件:FrameworkSQLiteDatabase.java
@Override
public Cursor rawQuery(final SupportSQLiteQuery supportQuery) {
return rawQueryWithFactory(new SQLiteDatabase.CursorFactory() {
@Override
public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery,
String editTable, SQLiteQuery query) {
supportQuery.bindTo(new FrameworkSQLiteProgram(query));
return new SQLiteCursor(masterQuery, editTable, query);
}
}, supportQuery.getSql(), EMPTY_STRING_ARRAY, null);
}
项目:joogar
文件:JoogarCursorFactory.java
@SuppressWarnings("deprecation")
public Cursor newCursor(SQLiteDatabase sqLiteDatabase,
SQLiteCursorDriver sqLiteCursorDriver,
String editTable,
SQLiteQuery sqLiteQuery) {
if(Joogar.isDebug()) {
Joogar.getInstance().getLogger().d(sqLiteQuery.toString());
}
return new SQLiteCursor(sqLiteDatabase, sqLiteCursorDriver, editTable, sqLiteQuery);
}
项目:CPOrm
文件:CPOrmCursorFactory.java
@Override
public Cursor newCursor(SQLiteDatabase sqLiteDatabase, SQLiteCursorDriver sqLiteCursorDriver, String tableName, SQLiteQuery sqLiteQuery) {
if (debugEnabled) {
CPOrmLog.d(sqLiteQuery.toString());
}
return new SQLiteCursor(sqLiteCursorDriver, tableName, sqLiteQuery);
}
项目:ApkTrack
文件:SugarCursorFactory.java
@SuppressWarnings("deprecation")
public Cursor newCursor(SQLiteDatabase sqLiteDatabase,
SQLiteCursorDriver sqLiteCursorDriver,
String editTable,
SQLiteQuery sqLiteQuery) {
if (debugEnabled) {
Log.d("SQL Log", sqLiteQuery.toString());
}
return new SQLiteCursor(sqLiteDatabase, sqLiteCursorDriver, editTable, sqLiteQuery);
}
项目:FullRobolectricTestSample
文件:MergeCursorTest.java
private SQLiteCursor setupTable(final String createSql, final String[] insertions, final String selectSql) {
database.execSQL(createSql);
for (String insert : insertions) {
database.execSQL(insert);
}
Cursor cursor = database.rawQuery(selectSql, null);
assertThat(cursor).isInstanceOf(SQLiteCursor.class);
return (SQLiteCursor) cursor;
}
项目:commcare-android
文件:LegacyCommCareDBCursorFactory.java
@Override
public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery, String editTable, SQLiteQuery query) {
if (models == null || !models.containsKey(editTable)) {
return new SQLiteCursor(db, masterQuery, editTable, query);
} else {
EncryptedModel model = models.get(editTable);
return new DecryptingCursor(db, masterQuery, editTable, query, model, getCipherPool());
}
}
项目:juahya
文件:DataProvider.java
public android.database.sqlite.SQLiteCursor query(String SQL) {
// getDB();
SQLiteDatabase db = getWritableDatabase();
// SQLiteDatabase db = this.getReadableDatabase();
if(db.isOpen()){
SQLiteCursor cursor = (android.database.sqlite.SQLiteCursor) db
.rawQuery(SQL, null);
return cursor;
}else{
return null;
}
}
项目:juahya
文件:DataProvider.java
public android.database.sqlite.SQLiteCursor query(String SQL,String[] bindArgs) {
// getDB();
SQLiteDatabase db = getWritableDatabase();
// SQLiteDatabase db = this.getReadableDatabase();
if(db.isOpen()){
SQLiteCursor cursor = (android.database.sqlite.SQLiteCursor) db
.rawQuery(SQL, bindArgs);
return cursor;
}else{
return null;
}
}
项目:juahya
文件:DataProvider.java
public android.database.sqlite.SQLiteCursor getCursor(String TableName, String[] columns, String selection,String[] selectionArgs, String groupBy, String having,String orderBy )
{
SQLiteDatabase db = getWritableDatabase();
SQLiteCursor cursor= (android.database.sqlite.SQLiteCursor)db.query(TableName, columns, selection, selectionArgs, groupBy, having, orderBy);
// db.close();
return cursor;
}
项目:NexusData
文件:DatabaseHelper.java
@SuppressWarnings("deprecation")
@Override
public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery,
String editTable, SQLiteQuery query) {
LOG.debug(query.toString());
// non-deprecated API is only available in API 11
return new SQLiteCursor(db, masterQuery, editTable, query);
}
项目:it-is-mine
文件:ItemListFragment.java
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
final SQLiteCursor row = (SQLiteCursor) cursorAdapter.getItem(position);
String itemIdTag = row.getString(row.getColumnIndex(DatabaseHelper.KEY_ITEM_ID_TAG));
ItemActivity.start(getActivity(), itemIdTag);
}
项目:wifiLazooo-android
文件:MainActivity.java
@Override
public boolean onSuggestionClick(int position) {
SQLiteCursor cursor = (SQLiteCursor) searchView.getSuggestionsAdapter().getItem(position);
int indexColumnSuggestion = cursor.getColumnIndex(SuggestionsDatabase.FIELD_SUGGESTION);
searchView.setQuery(cursor.getString(indexColumnSuggestion), false);
return true;
}
项目:mv-fieldguide-android
文件:FieldGuideDatabase.java
@Override
public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery,
String editTable, SQLiteQuery query) {
if (debugQueries) {
Log.d("SQL", query.toString());
}
return new SQLiteCursor(db, masterQuery, editTable, query);
}
项目:scrumchatter
文件:ScrumChatterProvider.java
/**
* Log the query of the given cursor.
*/
private void logCursor(Cursor cursor, String[] selectionArgs) {
try {
Field queryField = SQLiteCursor.class.getDeclaredField("mQuery");
queryField.setAccessible(true);
SQLiteQuery sqliteQuery = (SQLiteQuery) queryField.get(cursor);
Log.v(TAG, sqliteQuery.toString() + ": " + Arrays.toString(selectionArgs));
} catch (Exception e) {
Log.v(TAG, e.getMessage(), e);
}
}
项目:utexas-utilities
文件:BuildingDatabase.java
public Cursor query(String tablename, String[] columns, String selection,
String[] selectionArgs, String groupBy, String having, String orderBy) {
SQLiteCursor c = (SQLiteCursor) getReadableDatabase().query(
tablename,
columns,
KEY_SUGGEST_COLUMN_TEXT_1 + " LIKE '%" + selection + "%' OR "
+ KEY_SUGGEST_COLUMN_TEXT_2 + " LIKE '%" + selection + "%'", selectionArgs,
groupBy, having, orderBy);
c.moveToFirst();
return c;
}
项目:bunurong-fieldguide-Android
文件:FieldGuideDatabase.java
@Override
public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery,
String editTable, SQLiteQuery query) {
if (debugQueries) {
Log.d("SQL", query.toString());
}
return new SQLiteCursor(db, masterQuery, editTable, query);
}
项目:iBurn-Android
文件:FrameworkSQLiteDatabase.java
@Override
public Cursor query(final SupportSQLiteQuery supportQuery) {
return mDelegate.rawQueryWithFactory((db, masterQuery, editTable, query) -> {
supportQuery.bindTo(new FrameworkSQLiteProgram(query));
return new SQLiteCursor(masterQuery, editTable, query);
}, supportQuery.getSql(), EMPTY_STRING_ARRAY, null);
}