private void updateDownloadedFiles(SQLiteDatabase db,String newAccountName,String oldAccountName){
  String whereClause=ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " + ProviderTableMeta.FILE_STORAGE_PATH+ " IS NOT NULL";
  Cursor c=db.query(ProviderTableMeta.FILE_TABLE_NAME,null,whereClause,new String[]{newAccountName},null,null,null);
  try {
    if (c.moveToFirst()) {
      String oldAccountPath=FileStorageUtils.getSavePath(oldAccountName);
      String newAccountPath=FileStorageUtils.getSavePath(newAccountName);
      File oldAccountFolder=new File(oldAccountPath);
      File newAccountFolder=new File(newAccountPath);
      oldAccountFolder.renameTo(newAccountFolder);
      do {
        String oldPath=c.getString(c.getColumnIndex(ProviderTableMeta.FILE_STORAGE_PATH));
        OCFile file=new OCFile(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_PATH)));
        String newPath=FileStorageUtils.getDefaultSavePathFor(newAccountName,file);
        ContentValues cv=new ContentValues();
        cv.put(ProviderTableMeta.FILE_STORAGE_PATH,newPath);
        db.update(ProviderTableMeta.FILE_TABLE_NAME,cv,ProviderTableMeta.FILE_STORAGE_PATH + "=?",new String[]{oldPath});
        Log_OC.v("SQL","Updated path of downloaded file: old file name == " + oldPath + ", new file name == "+ newPath);
      }
 while (c.moveToNext());
    }
  }
  finally {
    c.close();
  }
}

private void updateDownloadedFiles ( SQLiteDatabase db , String newAccountName , String oldAccountName ) { String whereClause = ProviderTableMeta . FILE_ACCOUNT_OWNER + "=? AND " + ProviderTableMeta . FILE_STORAGE_PATH + " IS NOT NULL" ; Cursor c = db . query ( ProviderTableMeta . FILE_TABLE_NAME , null , whereClause , new String [ ] { newAccountName } , null , null , null ) ; try { if ( c . moveToFirst ( ) ) { String oldAccountPath = FileStorageUtils . getSavePath ( oldAccountName ) ; String newAccountPath = FileStorageUtils . getSavePath ( newAccountName ) ; File oldAccountFolder = new File ( oldAccountPath ) ; File newAccountFolder = new File ( newAccountPath ) ; oldAccountFolder . renameTo ( newAccountFolder ) ; do { String oldPath = c . getString ( c . getColumnIndex ( ProviderTableMeta . FILE_STORAGE_PATH ) ) ; OCFile file = new OCFile ( c . getString ( c . getColumnIndex ( ProviderTableMeta . FILE_PATH ) ) ) ; String newPath = FileStorageUtils . getDefaultSavePathFor ( newAccountName , file ) ; ContentValues cv = new ContentValues ( ) ; cv . put ( ProviderTableMeta . FILE_STORAGE_PATH , newPath ) ; db . update ( ProviderTableMeta . FILE_TABLE_NAME , cv , ProviderTableMeta . FILE_STORAGE_PATH + "=?" , new String [ ] { oldPath } ) ; Log_OC . v ( "SQL" , "Updated path of downloaded file: old file name == " + oldPath + ", new file name == " + newPath ) ; } while ( c . moveToNext ( ) ) ; } } finally { c . close ( ) ; } }
rename the local owncloud folder of one account to match the a rename of the account itself . updates the table of files in database so that the paths to the local files keep being the same .
