Android SQLiteException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android SQLiteException class.

This code example shows how to use the following methods:getMessage
        return outInfo.lowMemory;
    } 
 
    // FIXME: need to optimize this method. 
    private static boolean isLowMemory(SQLiteException e) {
        return e.getMessage().equals(SQLITE_EXCEPTION_DETAIL_MESSAGE);
    } 
 
    public static void checkSQLiteException(Context context, SQLiteException e) {
        if (isLowMemory(e)) {
            Toast.makeText(context, com.android.internal.R.string.low_memory,
                    Toast.LENGTH_SHORT).show();
        } else { 
            throw e;
        } 
    } 
 
    public static Cursor query(Context context, ContentResolver resolver, Uri uri,
            String[] projection, String selection, String[] selectionArgs, String sortOrder) {
        try { 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:e, getMessage
        // Forbidden being instantiated. 
    } 
 
    // FIXME: need to optimize this method. 
    private static boolean isLowMemory(SQLiteException e) {
        return e.getMessage().equals(SQLITE_EXCEPTION_DETAIL_MESSAGE);
    } 
 
    public static void checkSQLiteException(Context context, SQLiteException e) {
        if (isLowMemory(e)) {
            Toast.makeText(context, "Low Memory",
                    Toast.LENGTH_SHORT).show();
        } else { 
            throw e;
        } 
    } 
 
    public static Cursor query(Context context, ContentResolver resolver, Uri uri,
            String[] projection, String selection, String[] selectionArgs, String sortOrder) {
        try { 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getMessage
        log("Creating database table for " + getTableName()); 
        String createStatement = DbUtils.getCreateTable(getTableName());
        try { 
            db.execSQL(createStatement);
        } catch (SQLiteException ex) {
            if (ex.getMessage().startsWith("table " + getTableName() + " already exists: ")) {
                log("Table already exists: " + getTableName()); 
            } else { 
                log("Error executing SQL: " + createStatement, ex);
                throw ex;
            } 
        } 
 
    } 
 
    @Override 
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        log("Database version changed from " + oldVersion + " to " + newVersion);
 
        db.execSQL("DROP TABLE IF EXISTS " + getTableName());
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:toString
	public QueryExecutionContainerImpl(SQLiteDatabase db){
		this.db = db;
	} 
	 
	private void throwError(SQLiteException e){
		throw new QueryExecutionException("SQLiteAndroid error:" + e.toString());
	} 
	 
 
	@Override 
	public void executeOnly(Query q) {		
		Log.trace("Executing: %s", q);
		 
		try { 
			db.execSQL(q.getExecutableSql());
		} catch (SQLiteException e) {
			throwError(e);
		} 
	} 
 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
        try { 
            mIsInitializing = true;
            String path = databaseDirectory(mContext) + File.separator + mName;
            db = SQLiteDatabase.openDatabase(path, mFactory, SQLiteDatabase.OPEN_READONLY | SQLiteDatabase.NO_LOCALIZED_COLLATORS);
            if (db.getVersion() != mNewVersion) {
                throw new SQLiteException("Can't upgrade read-only database from version " +
                        db.getVersion() + " to " + mNewVersion + ": " + path);
            } 
 
            onOpen(db);
            Log.w(TAG, "Opened " + mName + " in read-only mode");
            mDatabase = db;
            return mDatabase;
        } finally { 
            mIsInitializing = false;
            if (db != null && db != mDatabase) db.close();
        } 
    } 
 
    /** 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:printStackTrace
			final Cursor cursor = mDb.query(tableName, columns, selection,
					selectionArgs, null, null, sortOrder);
 
			return cursor;
		} catch (SQLiteException e) {
			e.printStackTrace();
		} 
		return null; 
	} 
 
	public Cursor query(String tableName, String[] columns, String selection,
			String[] selectionArgs, String sortOrder, String limit) {
		try { 
			return mDb.query(tableName, columns, selection, selectionArgs,
					null, null, sortOrder, limit);
		} catch (SQLiteException e) {
			e.printStackTrace();
		} 
		return null; 
	} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getMessage
        return outInfo.lowMemory;
    } 
 
    // FIXME: need to optimize this method. 
    private static boolean isLowMemory(SQLiteException e) {
        return e.getMessage().equals(SQLITE_EXCEPTION_DETAIL_MESSAGE);
    } 
 
    public static void checkSQLiteException(Context context, SQLiteException e) {
        if (isLowMemory(e)) {
            Toast.makeText(context, com.android.internal.R.string.low_memory,
                    Toast.LENGTH_SHORT).show();
        } else { 
            throw e;
        } 
    } 
 
    public static Cursor query(Context context, ContentResolver resolver, Uri uri,
            String[] projection, String selection, String[] selectionArgs, String sortOrder) {
        try { 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
        SQLiteDatabase db = null;
        try { 
            mIsInitializing = true;
            db = SQLiteDatabase.openDatabase(mDbFilePath, mFactory, SQLiteDatabase.OPEN_READONLY);
            if (db.getVersion() != mNewVersion) {
                throw new SQLiteException("Can't upgrade read-only database from version " +
                        db.getVersion() + " to " + mNewVersion + ": " + mDbFilePath);
            } 
 
            onOpen(db);
            Log.w(TAG, "Opened " + mDbFilePath + " in read-only mode");
            mDatabase = db;
            return mDatabase;
        } finally { 
            mIsInitializing = false;
            if (db != null && db != mDatabase) db.close();
        } 
    } 
 
    /** 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getCause, getMessage
			String myPath = DB_PATH + DB_NAME;
			checkDB = SQLiteDatabase.openDatabase(myPath, null,
					SQLiteDatabase.OPEN_READONLY | SQLiteDatabase.NO_LOCALIZED_COLLATORS);
 
		} catch (SQLiteException e) {
			Log.e("DatabaseHelper.checkDataBase",""+e.getMessage()+", Cause: "+e.getCause());
		} 
		if (checkDB != null) {
			checkDB.close();
		} 
		return checkDB != null ? true : false;
	} 
 
	/** 
	 * Copies database from local assets-folder to the just created 
	 * empty database in the system folder, from where it can be accessed and 
	 * handled. This is done by transferring byte-streams. 
	 * */ 
	private void copyDataBase() throws IOException { 
		InputStream myInput = myContext.getAssets().open(DB_NAME);
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getMessage
		try { 
			SQLiteDatabase db = SQLiteDatabase.openDatabase(mDatabasePath + "/" + mName, mFactory, SQLiteDatabase.OPEN_READWRITE);
			Log.i(TAG, "successfully opened database " + mName);
			return db;
		} catch (SQLiteException e) {
			Log.w(TAG, "could not open database " + mName + " - " + e.getMessage());
			return null; 
		} 
	} 
 
	private void copyDatabaseFromAssets() throws SQLiteAssetException { 
		Log.w(TAG, "copying database from assets...");
 
		try { 
			InputStream zipFileStream = mContext.getAssets().open(mArchivePath);
			File f = new File(mDatabasePath + "/");
			if (!f.exists()) { f.mkdir(); }
 
			ZipInputStream zis = getFileFromZip(zipFileStream);
			if (zis == null) {
5
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Android SQLiteException Questions & Answers:

See Code Examples for Android SQLiteException Methods: