本文整理汇总了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";
}
示例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);
}
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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);
}
示例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);
}
示例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");
}
});
}
示例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);
}
示例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);
}
}
示例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;
}
示例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();
}
});
}