当前位置: 首页>>代码示例>>Java>>正文


Java SQLiteDatabase.isReadOnly方法代码示例

本文整理汇总了Java中android.database.sqlite.SQLiteDatabase.isReadOnly方法的典型用法代码示例。如果您正苦于以下问题:Java SQLiteDatabase.isReadOnly方法的具体用法?Java SQLiteDatabase.isReadOnly怎么用?Java SQLiteDatabase.isReadOnly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.database.sqlite.SQLiteDatabase的用法示例。


在下文中一共展示了SQLiteDatabase.isReadOnly方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
@Override
		public void onCreate(SQLiteDatabase sqLiteDatabase) {
			if (!sqLiteDatabase.isReadOnly()){
			sqLiteDatabase.execSQL("PRAGMA foreign_key=ON");
			}

//			sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " +
//			KEYVAL_TABLE_NAME + "(" + KEYVAL_COLUMN_KEY + " TEXT PRIMARY KEY, " +
//			KEYVAL_COLUMN_VAL + " TEXT)");

			sqLiteDatabase.execSQL(CREATE_TABLE_KEYVAL);
		}
 
开发者ID:FrogSquare,项目名称:GodotSQL,代码行数:13,代码来源:KeyValDatabase.java

示例2: onOpen

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
@Override
public void onOpen(SQLiteDatabase db) {
    super.onOpen(db);
    if (!db.isReadOnly()) {
        db.execSQL("PRAGMA foreign_keys=ON;");
    }
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:8,代码来源:DBHelper.java

示例3: onOpen

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
@Override
public void onOpen(SQLiteDatabase db) {
	super.onOpen(db);

	if (!db.isReadOnly()) {
		// Enable or disable foreign key constraints
		db.execSQL("PRAGMA foreign_keys=" + FOREIGN_KEY_CONSTRAINTS + ";");
	}
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:10,代码来源:DatabaseHelper.java

示例4: onOpen

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
/**
 * Add initial plant data when the app launches for the first time.
 * @param db The database to insert data
 */
@Override
public void onOpen(SQLiteDatabase db) {
    super.onOpen(db);
    // Only update the database if it's writable
    if (db.isReadOnly()) {
        return;
    }
    // Only insert initial plant data if the plant database is empty
    Cursor cursor = db.query(PlantEntry.TABLE_NAME, null, null, null, null, null, null);
    if (cursor.moveToFirst()) {
        return;
    }
    cursor.close();

    // Plant database is empty. Add all the plants.
    String[] names = context.getResources().getStringArray(R.array.plant_names);
    String[] descriptions = context.getResources().getStringArray(R.array.plant_descriptions);
    int[] prices = context.getResources().getIntArray(R.array.plant_prices);

    if (names.length != descriptions.length
            && descriptions.length != prices.length) {
        throw new IllegalStateException("There should be an equal number of plant names/descriptions/prices");
    }

    for (int i = 0; i < names.length; i++) {
        ContentValues values = new ContentValues();
        values.put(PlantEntry.COLUMN_NAME, names[i]);
        values.put(PlantEntry.COLUMN_DESCRIPTION, descriptions[i]);
        values.put(PlantEntry.COLUMN_PRICE, prices[i]);
        values.put(PlantEntry.COLUMN_CART_QUANTITY, 0);
        values.put(PlantEntry.COLUMN_PURCHASED_QUANTITY, 0);
        db.insert(PlantEntry.TABLE_NAME, null, values);
    }
    context.getContentResolver().notifyChange(PlantEntry.CONTENT_URI, null);
}
 
开发者ID:laramartin,项目名称:android_firebase_green_thumb,代码行数:40,代码来源:DbHelper.java

示例5: onOpen

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
@Override
public void onOpen(SQLiteDatabase db) {
    super.onOpen(db);

    if (!db.isReadOnly()) {
        db.execSQL("PRAGMA foreign_keys=ON;");
    }
}
 
开发者ID:marcelohanel,项目名称:PokerBankroll,代码行数:9,代码来源:DBHelper.java

示例6: isDbSafe

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
private static boolean isDbSafe(SQLiteDatabase db) {
	return db.isOpen() && !db.isReadOnly() && !db.isDbLockedByCurrentThread();
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:4,代码来源:Service.java


注:本文中的android.database.sqlite.SQLiteDatabase.isReadOnly方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。