当前位置: 首页>>代码示例>>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;未经允许,请勿转载。