List of usage examples for android.database.sqlite SQLiteDatabase OPEN_READONLY
int OPEN_READONLY
To view the source code for android.database.sqlite SQLiteDatabase OPEN_READONLY.
Click Source Link
From source file:Main.java
private static SQLiteDatabase getDataBase() { return SQLiteDatabase.openDatabase(getDBPath(), null, SQLiteDatabase.OPEN_READONLY); }
From source file:Main.java
public static boolean exists() { SQLiteDatabase checkDB = null;/*from w ww .j a v a 2 s. co m*/ try { checkDB = SQLiteDatabase.openDatabase(CHIRSTMAIS_IS_COMING, null, SQLiteDatabase.OPEN_READONLY); checkDB.close(); } catch (SQLiteException ex) { // database doesn't exist yet. } return checkDB != null ? true : false; }
From source file:Main.java
/** * Check if the database exist/*from w w w . ja v a 2s .c om*/ * * @return true if it exists, false if it doesn't */ public static boolean checkDataBase(Context context) { SQLiteDatabase checkDB = null; int count = 0; try { if (android.os.Build.VERSION.SDK_INT >= 17) { DB_PATH = context.getApplicationInfo().dataDir + "/databases/"; } else { DB_PATH = "/data/data/" + context.getPackageName() + "/databases/"; } checkDB = SQLiteDatabase.openDatabase(DB_PATH + DATABASE_NAME, null, SQLiteDatabase.OPEN_READONLY); String selectRegistros = "SELECT COUNT(*) FROM Grupo_Gastos"; Cursor mCursor = checkDB.query(true, "Grupo_Gastos", new String[] { "_id" }, null, null, null, null, null, null); count = mCursor.getCount(); checkDB.close(); } catch (SQLiteException e) { // database doesn't exist yet. return false; } return count > 0; }
From source file:org.thomnichols.android.gmarks.WebViewCookiesDB.java
List<Cookie> getCookies() { List<Cookie> cookies = new ArrayList<Cookie>(); SQLiteDatabase db = openDatabase(SQLiteDatabase.OPEN_READONLY); if (db == null) return cookies; try {/*from ww w . ja v a 2 s. c o m*/ db.execSQL("PRAGMA read_uncommitted = true;"); Cursor cursor = db.query(TABLE_NAME, COLUMNS, null, null, null, null, null); while (cursor.moveToNext()) { BasicClientCookie c = new BasicClientCookie(cursor.getString(COL_NAME), cursor.getString(COL_VALUE)); c.setDomain(cursor.getString(COL_DOMAIN)); c.setPath(cursor.getString(COL_PATH)); Long expiry = cursor.getLong(COL_EXPIRES); if (expiry != null) c.setExpiryDate(new Date(expiry)); c.setSecure(cursor.getShort(COL_SECURE) == 1); Log.d(TAG, "Got cookie: " + c.getName()); cookies.add(c); } cursor.close(); // cursor = db.query(TABLE_NAME, new String[] {"count(name)"}, null, null, null, null, null); // cursor.moveToFirst(); // Log.d("WEBVIEW DB QUERY", "COunt: " + cursor.getLong(0) ); // cursor.close(); return cookies; } finally { db.close(); } }
From source file:com.panoskrt.dbadapter.DBAdapter.java
public void copyDB() { try {/* w w w .j a va 2s. c o m*/ try { database = SQLiteDatabase.openDatabase(dbPath + dbName, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { // Checking if required dirs exist as sometimes they do not and // they need to be created. File dbDir = new File(dbPath); if (!dbDir.exists()) { dbDir.mkdirs(); } // Copying db from assets to db directory. InputStream in = context.getAssets().open(dbName); OutputStream out = new FileOutputStream(dbPath + dbName); bufCopy(in, out); } } catch (IOException ex) { ex.printStackTrace(); } if (database != null) { database.close(); } }
From source file:com.codebutler.farebot.core.DBUtil.java
public SQLiteDatabase openDatabase() throws SQLException, IOException { if (mDatabase != null) { return mDatabase; }/*from www . j a va 2 s . co m*/ if (!this.hasDatabase()) { this.copyDatabase(); } mDatabase = SQLiteDatabase.openDatabase(getDBFile().getPath(), null, SQLiteDatabase.OPEN_READONLY); return mDatabase; }
From source file:com.codebutler.farebot.transit.ovc.OVChipDBUtil.java
public SQLiteDatabase openDatabase() throws SQLException, IOException { if (mDatabase != null) { return mDatabase; }//from w w w. ja v a2 s . c o m if (!this.hasDatabase()) { this.copyDatabase(); } mDatabase = SQLiteDatabase.openDatabase(new File(DB_PATH, DB_NAME).getPath(), null, SQLiteDatabase.OPEN_READONLY); return mDatabase; }
From source file:com.panoskrt.dbadapter.DBAdapter.java
public SQLiteDatabase openDB() { database = SQLiteDatabase.openDatabase(dbPath + dbName, null, SQLiteDatabase.OPEN_READONLY); return database; }
From source file:com.codebutler.farebot.card.felica.DBUtil.java
public SQLiteDatabase openDatabase() throws SQLException, IOException { if (mDatabase != null) { return mDatabase; }/* w w w.ja v a 2 s .co m*/ if (!this.hasDatabase()) { this.copyDatabase(); } mDatabase = SQLiteDatabase.openDatabase(new File(DB_PATH, DB_NAME).getPath(), null, SQLiteDatabase.OPEN_READONLY); return mDatabase; }
From source file:com.example.ryutasakamoto.readfelica.util.DBUtil.java
public SQLiteDatabase openDatabase() throws SQLException, IOException { if (mDatabase != null) { return mDatabase; }/*from w w w.j a va2 s . com*/ if (!this.hasDatabase()) { this.copyDatabase(); } mDatabase = SQLiteDatabase.openDatabase(getDBFile().getPath(), null, SQLiteDatabase.OPEN_READONLY); return mDatabase; }