android_database_sqlite


pattern_12 (3 partitions, 41 files)


android.database.sqlite.SQLiteQueryBuilder.query


Cluster 2 (6 files, similarity: 0.718)

googlesamples_____io2015-codelabs_____RecipeContentProvider
    public Cursor getRecipe(Uri uri) {
        SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
        queryBuilder.setTables(RecipeTable.TABLE);
        String[] projection = { RecipeTable.ID, RecipeTable.TITLE,
                RecipeTable.DESCRIPTION, RecipeTable.PHOTO,
                RecipeTable.PREP_TIME};
        SQLiteDatabase db = database.getReadableDatabase();
        queryBuilder.appendWhere(RecipeTable.ID + "='"
                + uri.getLastPathSegment() + "'");
        Cursor cursor = queryBuilder.query(db, projection, null,
                null, null, null, null);
        cursor.setNotificationUri(getContext().getContentResolver(), uri);

        return cursor;
    }
            
tiann_____understand-plugin-framework_____TestContentProvider
    @Nullable
    @Override
    public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
        SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
        SQLiteDatabase db = mDb.getReadableDatabase();
        qb.setTables(TABLE_NAME);
        Cursor c = qb.query(db, projection, selection, null, null, null, sortOrder);
        c.setNotificationUri(getContext().getContentResolver(), uri);
        return c;
    }
            
Deletescape-Media_____Lawnchair_____LauncherProvider
    @Override
    public Cursor query(@NonNull Uri uri, String[] projection, String selection,
                        String[] selectionArgs, String sortOrder) {
        createDbIfNotExists();

        SqlArguments args = new SqlArguments(uri, selection, selectionArgs);
        SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
        qb.setTables(args.table);

        SQLiteDatabase db = mOpenHelper.getWritableDatabase();
        Cursor result = qb.query(db, projection, args.where, args.args, null, null, sortOrder);
        result.setNotificationUri(getContext().getContentResolver(), uri);

        return result;
    }
            

pattern_6 (3 partitions, 97 files)


android.database.sqlite.SQLiteDatabase.beginTransaction, android.database.sqlite.SQLiteDatabase.setTransactionSuccessful, android.database.sqlite.SQLiteDatabase.endTransaction


Cluster 1 (30 files, similarity: 0.475)

yeungeek_____monkey-android_____DbOpenHelper
    public void onCreate(SQLiteDatabase db) {
        db.beginTransaction();
        try {
            db.execSQL(Db.RepoTable.CREATE);
            db.setTransactionSuccessful();
        } finally {
            db.endTransaction();
        }
    }
            
Y0LANDA_____NoHttp_____CacheSQLHelper
    public void onCreate(SQLiteDatabase db) {
        db.beginTransaction();
        try {
            db.execSQL(SQL_CREATE_TABLE);
            db.execSQL(SQL_CREATE_UNIQUE_INDEX);
            db.setTransactionSuccessful();
        } finally {
            db.endTransaction();
        }
    }
            
xda_____XDA-One_____ForumDbHelper
    public void addAllRecursive(final Collection list) {
        final SQLiteDatabase database = getWritableDatabase();
        database.beginTransaction();

        try {
            addAllRecursive(database, list);
            database.setTransactionSuccessful();
        } finally {
            database.endTransaction();
        }
    }
            

pattern_5 (2 partitions, 93 files)


android.database.sqlite.SQLiteDatabase.close


Cluster 1 (29 files, similarity: 0.927)

AriaLyy_____Aria_____DbUtil
  private synchronized void close() {
    if (mDb != null) {
      mDb.close();
    }
  }
            
osmandapp_____Osmand_____BaseLocationIndexRepository
		if(db != null){
			// close previous db
			db.close();
		}
            
firebase_____firebase-android-sdk_____EncodedPathTest
    if (db != null) {
      db.close();
    }
            

pattern_15 (2 partitions, 74 files)


android.database.sqlite.SQLiteDatabase.execSQL, android.database.sqlite.SQLiteDatabase.execSQL, android.database.sqlite.SQLiteDatabase.execSQL


Cluster 1 (36 files, similarity: 0.813)

ankidroid_____Anki-Android_____MetaDB
        if (mMetaDb.getVersion() < 4) {
            mMetaDb.execSQL("DROP TABLE IF EXISTS languages;");
            mMetaDb.execSQL("DROP TABLE IF EXISTS customDictionary;");
            mMetaDb.execSQL("DROP TABLE IF EXISTS whiteboardState;");
        }
            
yiyuanliu_____FlipGank_____GankDbHelper
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(Contract.CREATE_TABLE_DATA);
        db.execSQL(Contract.CREATE_TABLE_CATEGORY);
        db.execSQL(Contract.CREATE_TABLE_HISTORY);
    }
            
k9mail_____k-9_____MigrationTo62
    public static void addServerIdColumnToFoldersTable(SQLiteDatabase db) {
        db.execSQL("ALTER TABLE folders ADD server_id TEXT");
        db.execSQL("UPDATE folders SET server_id = name");

        db.execSQL("DROP INDEX IF EXISTS folder_name");
        db.execSQL("CREATE INDEX folder_server_id ON folders (server_id)");
    }
            

pattern_4 (3 partitions, 128 files)


android.database.sqlite.SQLiteDatabase.delete


Cluster 1 (51 files, similarity: 0.681)

fire3_____sailorcast_____HistoryDbHelper
    public void deleteAlbum(String albumID, int siteID) {
        SQLiteDatabase db = this.getWritableDatabase();
        db.delete(TABLE_HISTORY, KEY_ALBUM_ID + " = ? AND " + KEY_ALBUM_SITE  + " = ?",
                new String[] { String.valueOf(albumID), String.valueOf(siteID) });
        db.close();
    }
            
dkim0419_____SoundRecorder_____DBHelper
    public void removeItemWithId(int id) {
        SQLiteDatabase db = getWritableDatabase();
        String[] whereArgs = { String.valueOf(id) };
        db.delete(DBHelperItem.TABLE_NAME, "_ID=?", whereArgs);
    }
            
stormzhang_____9GAG_____FeedsDataHelper
    public int deleteAll() {
        synchronized (DataProvider.DBLock) {
            DBHelper mDBHelper = DataProvider.getDBHelper();
            SQLiteDatabase db = mDBHelper.getWritableDatabase();
            int row = db.delete(FeedsDBInfo.TABLE_NAME, FeedsDBInfo.CATEGORY + "=?", new String[] {
                    String.valueOf(mCategory.ordinal())
            });
            return row;
        }
    }
            

pattern_9 (3 partitions, 68 files)


android.database.sqlite.SQLiteOpenHelper.onCreate


Cluster 2 (11 files, similarity: 0.967)

oubowu_____OuNews_____DaoMaster
        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
            dropAllTables(db, true);
            onCreate(db);
        }
            
zubinxiong_____Bgm38_____DaoMaster
        @Override
        public void onUpgrade(Database db, int oldVersion, int newVersion) {
            Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
            dropAllTables(db, true);
            onCreate(db);
        }
            
ZhaoKaiQiang_____JianDan_____DaoMaster
        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
            dropAllTables(db, true);
            onCreate(db);
        }
            

Cluster 0 (30 files, similarity: 0.728)

JakeWharton_____ActionBarSherlock_____LoaderThrottleSupport
       /**
        *
        * Demonstrates that the provider must consider what happens when the
        * underlying datastore is changed. In this sample, the database is upgraded the database
        * by destroying the existing data.
        * A real application should upgrade the database in place.
        */
       @Override
       public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

           // Logs that the database is being upgraded
           Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
                   + newVersion + ", which will destroy all old data");

           // Kills the table and existing data
           db.execSQL("DROP TABLE IF EXISTS notes");

           // Recreates the database with a new version
           onCreate(db);
       }
            
ParanoidAndroid_____android_frameworks_base_____LocalProvider
        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int currentVersion) {
            Log.w(TAG, "Upgrading test database from version " +
                  oldVersion + " to " + currentVersion +
                  ", which will destroy all old data");
            db.execSQL("DROP TABLE IF EXISTS data");
            onCreate(db);
        }
            
mcxiaoke_____minicat_____SQLiteHelper
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS " + StatusColumns.TABLE_NAME);
        db.execSQL("DROP TABLE IF EXISTS " + UserColumns.TABLE_NAME);
        db.execSQL("DROP TABLE IF EXISTS " + DirectMessageColumns.TABLE_NAME);
        db.execSQL("DROP TABLE IF EXISTS " + StatusUpdateInfoColumns.TABLE_NAME);
        onCreate(db);

    }