SQLiteDatabase setVersion - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for SQLiteDatabase setVersion method.

This code example shows how to use the following methods:execSQL, setVersion
            StringBuilder queryBuilder = new StringBuilder();
            queryBuilder.append(String.format("CREATE TABLE %s (", TABLE_NAME));
            TrackerEntry.buildCreationString(queryBuilder);
 
            queryBuilder.append(");");
            db.execSQL(queryBuilder.toString());
            db.setVersion(DB_VERSION);
        } 
 
        @Override 
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            // TODO: reimplement this when dB version changes 
            Log.w(LOG_TAG, "Upgrading database from version " + oldVersion
                            + " to " + newVersion
                            + ", which will destroy all old data"); 
            db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
            onCreate(db);
        } 
    } 
 
    private DatabaseHelper mOpenHelper;
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:close, beginTransaction, endTransaction, getVersion, setTransactionSuccessful
                    db = SQLiteDatabase.openOrCreateDatabase(new File(mPath, mName), mFactory);
                else 
                    db = mContext.openOrCreateDatabase(mName, 0, mFactory);
            } 
 
            int version = db.getVersion();
            if (version != mNewVersion) {
                db.beginTransaction();
                try { 
                    if (version == 0) {
                        onCreate(db);
                    } else { 
                        onUpgrade(db, version, mNewVersion);
                    } 
                    db.setVersion(mNewVersion);
                    db.setTransactionSuccessful();
                } finally { 
                    db.endTransaction();
                } 
            } 

8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:execSQL, setVersion
            StringBuilder queryBuilder = new StringBuilder();
            queryBuilder.append(String.format("CREATE TABLE %s (", TABLE_NAME));
            TrackerEntry.buildCreationString(queryBuilder);
 
            queryBuilder.append(");");
            db.execSQL(queryBuilder.toString());
            db.setVersion(DB_VERSION);
        } 
 
        @Override 
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            // TODO: reimplement this when dB version changes 
            Log.w(LOG_TAG, "Upgrading database from version " + oldVersion
                            + " to " + newVersion
                            + ", which will destroy all old data"); 
            db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
            onCreate(db);
        } 
    } 
 
    private DatabaseHelper mOpenHelper;
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:execSQL, setVersion
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(PROFILES_TABLE_CREATE);
	} 
	 
	private void upgrade6to7(SQLiteDatabase db){
		db.execSQL(PROFILES_TABLE_UPGRADE_6_7_1);
		db.execSQL(PROFILES_TABLE_UPGRADE_6_7_2);
		db.execSQL(PROFILES_TABLE_UPGRADE_6_7_3);
		db.execSQL(PROFILES_TABLE_UPGRADE_6_7_4);
	} 
	 
	/* (non-Javadoc) 
	 * @see android.database.sqlite.SQLiteOpenHelper#onUpgrade(android.database.sqlite.SQLiteDatabase, int, int) 
	 */ 
	@Override 
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		if (oldVersion == 2) {
			db.execSQL(PROFILES_TABLE_UPGRADE_2_3);
			db.execSQL(PROFILES_TABLE_UPGRADE_3_4);
			db.execSQL(PROFILES_TABLE_UPGRADE_4_5);

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:close, execSQL, setVersion
This code example shows how to use the following methods:close, isOpen, rawQuery, setLocale, setVersion
    	lastCursor=myDataBase.rawQuery(sql, selectionArgs);
    	return lastCursor;
    } 
     
    private void checkDBOpen() { 
    	if(myDataBase!=null && myDataBase.isOpen()) myDataBase.close();
    	if(lastCursor!=null && !lastCursor.isClosed()) lastCursor.close();
	} 
 
	public void execSQL(String sql){
		checkDBOpen(); 
    	openDataBase(); 
    	myDataBase.execSQL(sql);
    	close(); 
    } 
    /* 
    public SQLiteDatabase Instance(){ 
    	return myDataBase; 
    } 
    */ 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:execSQL, setVersion
        this.database = database;
        prepare(); 
    } 
 
    private void prepare() { 
        database.execSQL(CREATE_TABLE_GHOSTS);
        database.execSQL(CREATE_TABLE_CHANGE_VERSIONS);
        database.execSQL(String.format("CREATE UNIQUE INDEX IF NOT EXISTS ghost_version ON ghosts (bucketName, simperiumKey, version)"));
        database.setVersion(VERSION);
    } 
 
    protected void reset() { 
        database.delete(GHOSTS_TABLE_NAME, null, null);
        database.delete(VERSIONS_TABLE_NAME, null, null);
    } 
 
    @Override 
    public void resetBucket(Bucket bucket) {
        String[] args = { bucket.getName() };
        String where = "bucketName=?";
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:execSQL, setLocale, setVersion
	/* Method to create table in database */ 
	/**************************************/ 
	public void createTable() 
	{ 
		Log.i(TAG, "Creating SQLITE tables");
		db.setVersion(1);
		db.setLocale(Locale.getDefault());
 
		final String CREATE_USER_TABLE = "CREATE TABLE IF NOT EXISTS tbl_tweetification ("
				+ "username TEXT PRIMARY KEY," + "name TEXT);"; 
 
		db.execSQL(CREATE_USER_TABLE);
 
		final String CREATE_NOTIF_TABLE = "CREATE TABLE IF NOT EXISTS tbl_notifications (id INTEGER PRIMARY KEY AUTOINCREMENT, message TEST);";
		 
		db.execSQL(CREATE_NOTIF_TABLE);
		 
	} 
 
	/*************************************************/ 
	/* Method to insert new Twitter user in database */ 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:execSQL, setVersion
            } 
        } 
    } 
 
    private void createTable() { 
        mDatabase.execSQL("CREATE TABLE " + HTTPAUTH_TABLE_NAME
                + " (" + ID_COL + " INTEGER PRIMARY KEY, "
                + HTTPAUTH_HOST_COL + " TEXT, " + HTTPAUTH_REALM_COL
                + " TEXT, " + HTTPAUTH_USERNAME_COL + " TEXT, "
                + HTTPAUTH_PASSWORD_COL + " TEXT," + " UNIQUE ("
                + HTTPAUTH_HOST_COL + ", " + HTTPAUTH_REALM_COL
                + ") ON CONFLICT REPLACE);"); 
 
        mDatabase.setVersion(DATABASE_VERSION);
    } 
 
    /** 
     * Waits for the background initialization thread to complete and check the database creation 
     * status. 
     * 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:execSQL, setVersion
		} 
 
		@Override 
		public void onCreate(SQLiteDatabase db) {
			// create new database 
			db.execSQL("create table " + OtokouUserAdapter.TABLE_NAME + " (" + OtokouUserAdapter.COL_ID_NAME + " " + OtokouUserAdapter.COL_ID_TYPE + ", "
					+ OtokouUserAdapter.COL_1_NAME + " " + OtokouUserAdapter.COL_1_TYPE + ","
					+ OtokouUserAdapter.COL_2_NAME + " " + OtokouUserAdapter.COL_2_TYPE + ","
					+ OtokouUserAdapter.COL_3_NAME + " " + OtokouUserAdapter.COL_3_TYPE + ","
					+ OtokouUserAdapter.COL_4_NAME + " " + OtokouUserAdapter.COL_4_TYPE + ","
					+ OtokouUserAdapter.COL_5_NAME + " " + OtokouUserAdapter.COL_5_TYPE + ","
					+ OtokouUserAdapter.COL_6_NAME + " " + OtokouUserAdapter.COL_6_TYPE + ","
					+ OtokouUserAdapter.COL_7_NAME + " " + OtokouUserAdapter.COL_7_TYPE + ","
					+ OtokouUserAdapter.COL_8_NAME + " " + OtokouUserAdapter.COL_8_TYPE + ","
					+ OtokouUserAdapter.COL_9_NAME + " " + OtokouUserAdapter.COL_9_TYPE
					+ ");"); 
			 
			// delete related databases data 
			OtokouVehicleAdapter otokouVehicleAdapter = new OtokouVehicleAdapter(context).open();
			otokouVehicleAdapter.deleteAllVehicles().close();

5
CodeRank
Experience pair programming with AI  Get Codota for Java

Related SQLiteDatabase setVersion Questions & Answers:

setVersion Method Overview
Sets the database version.
See Code Examples for other Android SQLiteDatabase Methods: