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


Java DatabaseErrorHandler類代碼示例

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


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

示例1: SQLiteAssetHelper

import android.database.DatabaseErrorHandler; //導入依賴的package包/類
/**
 * Create a helper object to create, open, and/or manage a database in
 * a specified location.
 * This method always returns very quickly.  The database is not actually
 * created or opened until one of {@link #getWritableDatabase} or
 * {@link #getReadableDatabase} is called.
 *
 * @param context to use to open or create the database
 * @param name of the database file
 * @param storageDirectory to store the database file upon creation; caller must
 * ensure that the specified absolute path is available and can be written to
 * @param factory to use for creating cursor objects, or null for the default
 * @param version number of the database (starting at 1); if the database is older,
 * SQL file(s) contained within the application assets folder will be used to
 * upgrade the database
 */
public SQLiteAssetHelper(Context context, String name, String storageDirectory, CursorFactory factory, int version, DatabaseErrorHandler errorHandler) {
    super(context, name, factory, version, errorHandler);

    if (version < 1) throw new IllegalArgumentException("Version must be >= 1, was " + version);
    if (name == null) throw new IllegalArgumentException("Database name cannot be null");

    mContext = context;
    mName = name;
    mFactory = factory;
    mNewVersion = version;

    mAssetPath = ASSET_DB_PATH + "/" + name;
    if (storageDirectory != null) {
        mDatabasePath = storageDirectory;
    } else {
        mDatabasePath = context.getApplicationInfo().dataDir + "/databases";
    }
    mUpgradePathFormat = ASSET_DB_PATH + "/" + name + "_upgrade_%s-%s.sql";
}
 
開發者ID:albertogiunta,項目名稱:justintrain-client-android,代碼行數:36,代碼來源:SQLiteAssetHelper.java

示例2: openOrCreateDatabase

import android.database.DatabaseErrorHandler; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public SQLiteDatabase openOrCreateDatabase(String name, int mode, SQLiteDatabase.CursorFactory factory, DatabaseErrorHandler errorHandler) {
    if (dbMap.containsKey(name)) {
        return dbMap.get(name);
    }
    // 創建數據庫
    try {
        String path = DbPathUtils.getDbPath(name);

        ShadowSQLiteDatabase sdb = new ShadowSQLiteDatabase(path, 0, null);
        SQLiteDatabase       db  = new CGLibProxy().proxy(SQLiteDatabase.class, sdb);

        sdb.setMockDatabase(db);

        putSQLiteDatabase(name, db);

        return db;
    } catch (java.sql.SQLException e) {
        throw new android.database.SQLException("", e);
    }
}
 
開發者ID:kkmike999,項目名稱:YuiHatano,代碼行數:22,代碼來源:ShadowContext.java

示例3: openOrCreateDatabase

import android.database.DatabaseErrorHandler; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public SQLiteDatabase openOrCreateDatabase(String name, int mode, SQLiteDatabase.CursorFactory factory, DatabaseErrorHandler errorHandler) {
    if (dbMap.containsKey(name)) {
        return dbMap.get(name);
    }
    // 創建數據庫
    try {
        String path = staticGetDatabasePath(name).getPath();

        ShadowSQLiteDatabase sdb = new ShadowSQLiteDatabase(path, 0, null);
        SQLiteDatabase       db  = new CGLibProxy().proxy(SQLiteDatabase.class, sdb);

        sdb.setMockDatabase(db);

        putSQLiteDatabase(name, db);

        return db;
    } catch (java.sql.SQLException e) {
        throw new android.database.SQLException("", e);
    }
}
 
開發者ID:kkmike999,項目名稱:KBUnitTest,代碼行數:22,代碼來源:ShadowContext.java

示例4: SQLiteSDCardHelper

import android.database.DatabaseErrorHandler; //導入依賴的package包/類
/**
 * Create a helper object to create, open, and/or manage a database in 
 * a specified location.
 * This method always returns very quickly.  The database is not actually
 * created or opened until one of {@link #getWritableDatabase} or
 * {@link #getReadableDatabase} is called.
 *
 * <p>Accepts input param: a concrete instance of {@link DatabaseErrorHandler} to be
 * used to handle corruption when sqlite reports database corruption.</p>
 *
 * @param context          to use to open or create the database
 * @param name             of the database file
 * @param storageDirectory to store the database file upon creation; caller must
 *     ensure that the specified absolute path is available and can be written to  
 * @param factory to use for creating cursor objects, or null for the default
 * @param version number of the database (starting at 1); if the database is older,
 *     SQL file(s) contained within the application assets folder will be used to 
 *     upgrade the database
 * @param errorHandler the {@link DatabaseErrorHandler} to be used when sqlite reports database
 * corruption, or null to use the default error handler.
 */
public SQLiteSDCardHelper(Context context, String name, String storageDirectory, CursorFactory
        factory, int version, DatabaseErrorHandler errorHandler) {
    super(context, name, factory, version);

    if (version < 1) {
        throw new IllegalArgumentException("Version must be >= 1, was " + version);
    }
    if (name == null) {
        throw new IllegalArgumentException("Database name cannot be null");
    }

    mContext = context;
    mName = name;
    mFactory = factory;
    mNewVersion = version;
    mErrorHandler = errorHandler;

    if (storageDirectory != null) {
        mDatabasePath = storageDirectory;
    } else {
        mDatabasePath = context.getApplicationInfo().dataDir + File.separator + DB_PATH;
    }
}
 
開發者ID:yaming116,項目名稱:android-sdcard-helper,代碼行數:45,代碼來源:SQLiteSDCardHelper.java

示例5: openOrCreateDatabase

import android.database.DatabaseErrorHandler; //導入依賴的package包/類
@Override
public  SQLiteDatabase openOrCreateDatabase(String name,
                                                    int mode, SQLiteDatabase.CursorFactory factory,
                                                    @Nullable DatabaseErrorHandler errorHandler)
{
	final String dicDBpath = FlyingFileManager.getMyDicDBFilePath();

	File file = FlyingFileManager.getFile(dicDBpath);

	SQLiteDatabase db =SQLiteDatabase.openOrCreateDatabase(file, null);
	db.setVersion(DicSQLiteOpenHelper.DATABASE_VERSION);

	// SQLiteDatabase result = super.openOrCreateDatabase(name, mode, factory);
	if (Log.isLoggable(DEBUG_CONTEXT, Log.WARN))
	{
		Log.w(DEBUG_CONTEXT,
				"openOrCreateDatabase(" + name + ",,) = " + db.getPath());
	}
	return db;
}
 
開發者ID:birdcopy,項目名稱:Android-Birdcopy-Application,代碼行數:21,代碼來源:DicSQLiteOpenHelper.java

示例6: openOrCreateDatabase

import android.database.DatabaseErrorHandler; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
   public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory,
           DatabaseErrorHandler errorHandler) {
   	if (!ENBABLE_FILE) {
   		return super.openOrCreateDatabase(name, mode, factory, errorHandler);
   	}
   	
       File f = validateFilePath(name, true);
       int flags = SQLiteDatabase.CREATE_IF_NECESSARY;
       if ((mode & MODE_ENABLE_WRITE_AHEAD_LOGGING) != 0) {
           flags |= SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING;
       }
       SQLiteDatabase db = SQLiteDatabaseCompat.openDatabase(f.getPath(), factory, flags, errorHandler);
       setFilePermissionsFromMode(f.getPath(), mode, 0);
       return db;
   }
 
開發者ID:luoqii,項目名稱:ApkLauncher,代碼行數:18,代碼來源:FileContext.java

示例7: SQLHelper

import android.database.DatabaseErrorHandler; //導入依賴的package包/類
public SQLHelper(String _dbFilePath, DatabaseErrorHandler errHandler) {
    this.mCurDBFilePath = _dbFilePath;
    try {
        _db = SQLiteDatabase.openDatabase(mCurDBFilePath, null, 0, errHandler);
        isDataBase = true;
    } catch (Exception e) {
        isDataBase = false;
    }
}
 
開發者ID:WeiMei-Tian,項目名稱:editor-sql,代碼行數:10,代碼來源:SQLHelper.java

示例8: ShadowSQLiteOpenHelper

import android.database.DatabaseErrorHandler; //導入依賴的package包/類
public ShadowSQLiteOpenHelper(SQLiteOpenHelper realOpenHelper, Context context, String name, SQLiteDatabase.CursorFactory factory, int version,
                              DatabaseErrorHandler errorHandler) {
    if (version < 1) {
        throw new IllegalArgumentException("Version must be >= 1, was " + version);
    }

    mRealOpenHelper = realOpenHelper;
    mContext = context;
    mName = name;
    mFactory = factory;
    mNewVersion = version;
    mErrorHandler = errorHandler;
}
 
開發者ID:kkmike999,項目名稱:YuiHatano,代碼行數:14,代碼來源:ShadowSQLiteOpenHelper.java

示例9: SQLiteOpenHelper

import android.database.DatabaseErrorHandler; //導入依賴的package包/類
public SQLiteOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version, DatabaseErrorHandler errorHandler) {
    if (version < 1) {
        throw new IllegalArgumentException("Version must be >= 1, was " + version);
    }

    shadowSQLiteOpenHelper = new ShadowSQLiteOpenHelper(this, context, name, factory, version, errorHandler);
}
 
開發者ID:kkmike999,項目名稱:YuiHatano,代碼行數:8,代碼來源:SQLiteOpenHelper.java

示例10: DeleteOnDowngradeSQLiteOpenHelper

import android.database.DatabaseErrorHandler; //導入依賴的package包/類
public DeleteOnDowngradeSQLiteOpenHelper(Context context, String name, CursorFactory factory, int version,
        DatabaseErrorHandler errorHandler) {
    super(context, name, factory, version, errorHandler);
    mDatabaseFile = context.getDatabasePath(name);
}
 
開發者ID:archos-sa,項目名稱:aos-MediaLib,代碼行數:6,代碼來源:DeleteOnDowngradeSQLiteOpenHelper.java

示例11: DBOpenHelper

import android.database.DatabaseErrorHandler; //導入依賴的package包/類
public DBOpenHelper(Context context){
    this(context, DBNAME, null, VERSION, new DatabaseErrorHandler() {
        @Override
        public void onCorruption(SQLiteDatabase dbObj) {
            LogUtil.d("DBError","error occur");
        }
    });
}
 
開發者ID:rRemix,項目名稱:APlayer,代碼行數:9,代碼來源:DBOpenHelper.java

示例12: openOrCreateDatabase

import android.database.DatabaseErrorHandler; //導入依賴的package包/類
public SQLiteDatabase openOrCreateDatabase(final String name, final int mode,
        final SQLiteDatabase.CursorFactory factory, final DatabaseErrorHandler errorHandler) {
    verifyMethodCalledFromDelegate(
            "openOrCreateDatabase(String, Integer, SQLiteDatabase.CursorFactory, DatabaseErrorHandler)");
    return ((CallFun4<SQLiteDatabase, String, Integer, SQLiteDatabase.CursorFactory, DatabaseErrorHandler>) mSuperListeners
            .pop()).call(name, mode, factory, errorHandler);
}
 
開發者ID:passsy,項目名稱:CompositeAndroid,代碼行數:8,代碼來源:ActivityPlugin.java

示例13: openOrCreateDatabase

import android.database.DatabaseErrorHandler; //導入依賴的package包/類
@Override
public SQLiteDatabase openOrCreateDatabase(String name, int mode, SQLiteDatabase.CursorFactory factory, DatabaseErrorHandler errorHandler) {
    if (!mInPluginApk) {
        return super.openOrCreateDatabase(name, mode, factory, errorHandler);
    } else {
        return that.openOrCreateDatabase(name, mode, factory, errorHandler);
    }
}
 
開發者ID:AndyWing,項目名稱:dynamic-load-apk,代碼行數:9,代碼來源:GhostActivity.java

示例14: Configuration

import android.database.DatabaseErrorHandler; //導入依賴的package包/類
Configuration(@NonNull Context context, @Nullable String name,
              @Nullable SQLiteDatabase.CursorFactory factory,
              int version, @Nullable DatabaseErrorHandler errorHandler,
              @NonNull Callback callback) {
    this.context = context;
    this.name = name;
    this.factory = factory;
    this.version = version;
    this.callback = callback;
    this.errorHandler = errorHandler;
}
 
開發者ID:CaMnter,項目名稱:AndroidLife,代碼行數:12,代碼來源:SupportSQLiteOpenHelper.java

示例15: DatabaseHelper

import android.database.DatabaseErrorHandler; //導入依賴的package包/類
public DatabaseHelper(Context context, CursorFactory c){
	super(context, DATABASE_NAME, c, DB_VERSION, new DatabaseErrorHandler(){
		public void onCorruption(SQLiteDatabase dbObj) {
			Log.e("DBH.java", "Corruption detected: " + dbObj.getPath());
			Log.e("DBH.java", "Closing Database");
			dbObj.close();
		}
	});
}
 
開發者ID:JFrei86,項目名稱:rockkeeper,代碼行數:10,代碼來源:DatabaseHelper.java


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