Java Code Examples for android.database.sqlite.SQLiteDatabase#CREATE_IF_NECESSARY
The following examples show how to use
android.database.sqlite.SQLiteDatabase#CREATE_IF_NECESSARY .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
@Override public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory, DatabaseErrorHandler errorHandler) { checkMode(mode); File f = getDatabasePath(name); int flags = SQLiteDatabase.CREATE_IF_NECESSARY; if ((mode & MODE_ENABLE_WRITE_AHEAD_LOGGING) != 0) { flags |= SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING; } if ((mode & MODE_NO_LOCALIZED_COLLATORS) != 0) { flags |= SQLiteDatabase.NO_LOCALIZED_COLLATORS; } SQLiteDatabase db = SQLiteDatabase.openDatabase(f.getPath(), factory, flags, errorHandler); setFilePermissionsFromMode(f.getPath(), mode, 0); return db; }
Example 2
Source File: SQLitePlugin.java From react-native-sqlite-storage with MIT License | 6 votes |
DBRunner(final String dbname, ReadableMap options, CallbackContext cbc) { this.dbname = dbname; int openFlags = SQLiteDatabase.OPEN_READWRITE | SQLiteDatabase.CREATE_IF_NECESSARY; try { this.assetFilename = SQLitePluginConverter.getString(options,"assetFilename",null); if (this.assetFilename != null && this.assetFilename.length() > 0) { boolean readOnly = SQLitePluginConverter.getBoolean(options,"readOnly",false); openFlags = readOnly ? SQLiteDatabase.OPEN_READONLY : openFlags; } } catch (Exception ex){ FLog.e(TAG,"Error retrieving assetFilename or mode from options:",ex); } this.openFlags = openFlags; this.androidLockWorkaround = SQLitePluginConverter.getBoolean(options,"androidLockWorkaround",false); if (this.androidLockWorkaround) FLog.i(TAG, "Android db closing/locking workaround applied"); this.q = new LinkedBlockingQueue<DBQuery>(); this.openCbc = cbc; }
Example 3
Source File: AndroidDriver.java From alchemy with Apache License 2.0 | 6 votes |
@Override public SQLiteDb open(String path, boolean readOnly, boolean fullMutex) { int flags = 0; if (readOnly) { flags |= SQLiteDatabase.OPEN_READONLY; } else { flags |= SQLiteDatabase.OPEN_READWRITE; flags |= SQLiteDatabase.CREATE_IF_NECESSARY; } final SQLiteDatabase db = SQLiteDatabase.openDatabase(path, null, flags); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { db.setForeignKeyConstraintsEnabled(true); } else { db.execSQL("PRAGMA foreign_keys = ON;"); } return new AndroidDb(db); }
Example 4
Source File: ContextImpl.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory, DatabaseErrorHandler errorHandler) { checkMode(mode); File f = getDatabasePath(name); int flags = SQLiteDatabase.CREATE_IF_NECESSARY; if ((mode & MODE_ENABLE_WRITE_AHEAD_LOGGING) != 0) { flags |= SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING; } if ((mode & MODE_NO_LOCALIZED_COLLATORS) != 0) { flags |= SQLiteDatabase.NO_LOCALIZED_COLLATORS; } SQLiteDatabase db = SQLiteDatabase.openDatabase(f.getPath(), factory, flags, errorHandler); setFilePermissionsFromMode(f.getPath(), mode, 0); return db; }
Example 5
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
@Override public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory, DatabaseErrorHandler errorHandler) { checkMode(mode); File f = getDatabasePath(name); int flags = SQLiteDatabase.CREATE_IF_NECESSARY; if ((mode & MODE_ENABLE_WRITE_AHEAD_LOGGING) != 0) { flags |= SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING; } if ((mode & MODE_NO_LOCALIZED_COLLATORS) != 0) { flags |= SQLiteDatabase.NO_LOCALIZED_COLLATORS; } SQLiteDatabase db = SQLiteDatabase.openDatabase(f.getPath(), factory, flags, errorHandler); setFilePermissionsFromMode(f.getPath(), mode, 0); return db; }
Example 6
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
@Override public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory, DatabaseErrorHandler errorHandler) { checkMode(mode); File f = getDatabasePath(name); int flags = SQLiteDatabase.CREATE_IF_NECESSARY; if ((mode & MODE_ENABLE_WRITE_AHEAD_LOGGING) != 0) { flags |= SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING; } if ((mode & MODE_NO_LOCALIZED_COLLATORS) != 0) { flags |= SQLiteDatabase.NO_LOCALIZED_COLLATORS; } SQLiteDatabase db = SQLiteDatabase.openDatabase(f.getPath(), factory, flags, errorHandler); setFilePermissionsFromMode(f.getPath(), mode, 0); return db; }
Example 7
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
@Override public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory, DatabaseErrorHandler errorHandler) { checkMode(mode); File f = getDatabasePath(name); int flags = SQLiteDatabase.CREATE_IF_NECESSARY; if ((mode & MODE_ENABLE_WRITE_AHEAD_LOGGING) != 0) { flags |= SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING; } if ((mode & MODE_NO_LOCALIZED_COLLATORS) != 0) { flags |= SQLiteDatabase.NO_LOCALIZED_COLLATORS; } SQLiteDatabase db = SQLiteDatabase.openDatabase(f.getPath(), factory, flags, errorHandler); setFilePermissionsFromMode(f.getPath(), mode, 0); return db; }
Example 8
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
@Override public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory, DatabaseErrorHandler errorHandler) { checkMode(mode); File f = getDatabasePath(name); int flags = SQLiteDatabase.CREATE_IF_NECESSARY; if ((mode & MODE_ENABLE_WRITE_AHEAD_LOGGING) != 0) { flags |= SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING; } if ((mode & MODE_NO_LOCALIZED_COLLATORS) != 0) { flags |= SQLiteDatabase.NO_LOCALIZED_COLLATORS; } SQLiteDatabase db = SQLiteDatabase.openDatabase(f.getPath(), factory, flags, errorHandler); setFilePermissionsFromMode(f.getPath(), mode, 0); return db; }
Example 9
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
@Override public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory, DatabaseErrorHandler errorHandler) { checkMode(mode); File f = getDatabasePath(name); int flags = SQLiteDatabase.CREATE_IF_NECESSARY; if ((mode & MODE_ENABLE_WRITE_AHEAD_LOGGING) != 0) { flags |= SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING; } if ((mode & MODE_NO_LOCALIZED_COLLATORS) != 0) { flags |= SQLiteDatabase.NO_LOCALIZED_COLLATORS; } SQLiteDatabase db = SQLiteDatabase.openDatabase(f.getPath(), factory, flags, errorHandler); setFilePermissionsFromMode(f.getPath(), mode, 0); return db; }
Example 10
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
@Override public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory, DatabaseErrorHandler errorHandler) { checkMode(mode); File f = getDatabasePath(name); int flags = SQLiteDatabase.CREATE_IF_NECESSARY; if ((mode & MODE_ENABLE_WRITE_AHEAD_LOGGING) != 0) { flags |= SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING; } if ((mode & MODE_NO_LOCALIZED_COLLATORS) != 0) { flags |= SQLiteDatabase.NO_LOCALIZED_COLLATORS; } SQLiteDatabase db = SQLiteDatabase.openDatabase(f.getPath(), factory, flags, errorHandler); setFilePermissionsFromMode(f.getPath(), mode, 0); return db; }
Example 11
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
@Override public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory, DatabaseErrorHandler 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 = SQLiteDatabase.openDatabase(f.getPath(), factory, flags, errorHandler); setFilePermissionsFromMode(f.getPath(), mode, 0); return db; }
Example 12
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
@Override public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory, DatabaseErrorHandler 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 = SQLiteDatabase.openDatabase(f.getPath(), factory, flags, errorHandler); setFilePermissionsFromMode(f.getPath(), mode, 0); return db; }
Example 13
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
@Override public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory, DatabaseErrorHandler 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 = SQLiteDatabase.openDatabase(f.getPath(), factory, flags, errorHandler); setFilePermissionsFromMode(f.getPath(), mode, 0); return db; }
Example 14
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
@Override public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory, DatabaseErrorHandler 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 = SQLiteDatabase.openDatabase(f.getPath(), factory, flags, errorHandler); setFilePermissionsFromMode(f.getPath(), mode, 0); return db; }
Example 15
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
@Override public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory, DatabaseErrorHandler 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 = SQLiteDatabase.openDatabase(f.getPath(), factory, flags, errorHandler); setFilePermissionsFromMode(f.getPath(), mode, 0); return db; }
Example 16
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
@Override public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory, DatabaseErrorHandler 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 = SQLiteDatabase.openDatabase(f.getPath(), factory, flags, errorHandler); setFilePermissionsFromMode(f.getPath(), mode, 0); return db; }
Example 17
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
@Override public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory, DatabaseErrorHandler 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 = SQLiteDatabase.openDatabase(f.getPath(), factory, flags, errorHandler); setFilePermissionsFromMode(f.getPath(), mode, 0); return db; }