當前位置: 首頁>>代碼示例>>Java>>正文


Java SQLiteCursor類代碼示例

本文整理匯總了Java中android.database.sqlite.SQLiteCursor的典型用法代碼示例。如果您正苦於以下問題:Java SQLiteCursor類的具體用法?Java SQLiteCursor怎麽用?Java SQLiteCursor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SQLiteCursor類屬於android.database.sqlite包,在下文中一共展示了SQLiteCursor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: bindPreHoneycomb

import android.database.sqlite.SQLiteCursor; //導入依賴的package包/類
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));
    }
}
 
開發者ID:smukov,項目名稱:AvI,代碼行數:22,代碼來源:SQLiteAndroidDatabase.java

示例2: newCursor

import android.database.sqlite.SQLiteCursor; //導入依賴的package包/類
/**
 * {@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;
}
 
開發者ID:ngageoint,項目名稱:geopackage-android,代碼行數:22,代碼來源:GeoPackageCursorFactory.java

示例3: startAndStopManagingCursorTracksCursors

import android.database.sqlite.SQLiteCursor; //導入依賴的package包/類
@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);
}
 
開發者ID:qx,項目名稱:FullRobolectricTestSample,代碼行數:22,代碼來源:ActivityTest.java

示例4: getColumnType

import android.database.sqlite.SQLiteCursor; //導入依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:infinum,項目名稱:android_dbinspector,代碼行數:28,代碼來源:DatabaseHelper.java

示例5: columnIsExist

import android.database.sqlite.SQLiteCursor; //導入依賴的package包/類
/**
 * �����ֶ��Ƿ����
 * @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;
}
 
開發者ID:jixieshi999,項目名稱:juahya,代碼行數:21,代碼來源:DataProvider.java

示例6: tableIsExist

import android.database.sqlite.SQLiteCursor; //導入依賴的package包/類
/**
 * ����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;
}
 
開發者ID:jixieshi999,項目名稱:juahya,代碼行數:26,代碼來源:DataProvider.java

示例7: openDatabase

import android.database.sqlite.SQLiteCursor; //導入依賴的package包/類
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);
}
 
開發者ID:jberkel,項目名稱:whassup,代碼行數:20,代碼來源:Whassup.java

示例8: getCheckedIds

import android.database.sqlite.SQLiteCursor; //導入依賴的package包/類
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;
}
 
開發者ID:ziroby,項目名稱:dmassist,代碼行數:24,代碼來源:LoadEntity.java

示例9: query

import android.database.sqlite.SQLiteCursor; //導入依賴的package包/類
@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);
}
 
開發者ID:albertogiunta,項目名稱:justintrain-client-android,代碼行數:8,代碼來源:FrameworkSQLiteDatabase.java

示例10: getType

import android.database.sqlite.SQLiteCursor; //導入依賴的package包/類
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;
}
 
開發者ID:gzxishan,項目名稱:OftenPorter,代碼行數:32,代碼來源:TypeUtil.java

示例11: newCursor

import android.database.sqlite.SQLiteCursor; //導入依賴的package包/類
@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();
    }
  };
}
 
開發者ID:demidenko05,項目名稱:beige-software,代碼行數:14,代碼來源:CursorFactory.java

示例12: select

import android.database.sqlite.SQLiteCursor; //導入依賴的package包/類
@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();
    }
}
 
開發者ID:DanielSerdyukov,項目名稱:alchemy,代碼行數:11,代碼來源:AndroidQuery.java

示例13: newCursor

import android.database.sqlite.SQLiteCursor; //導入依賴的package包/類
@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));
}
 
開發者ID:ryansgot,項目名稱:forsuredbandroid,代碼行數:8,代碼來源:FSCursorFactory.java

示例14: newCursor

import android.database.sqlite.SQLiteCursor; //導入依賴的package包/類
@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));
}
 
開發者ID:hehonghui,項目名稱:simpledb,代碼行數:8,代碼來源:CloseCursorFactory.java

示例15: finalize

import android.database.sqlite.SQLiteCursor; //導入依賴的package包/類
@Override
protected void finalize() throws Throwable {
    try {
        if (!getWrappedCursor().isClosed()) {
            showLeakInfo((SQLiteCursor) getWrappedCursor());
            close();
        }
    } finally {
        super.finalize();
    }
}
 
開發者ID:hehonghui,項目名稱:simpledb,代碼行數:12,代碼來源:AutoCloseCursor.java


注:本文中的android.database.sqlite.SQLiteCursor類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。