use of android.database.sqlite.SQLiteDatabase in project platform_frameworks_base by android.
the class Mapper method clearMapping.
void clearMapping() {
final SQLiteDatabase database = mDatabase.getSQLiteDatabase();
database.beginTransaction();
try {
mInMappingIds.clear();
// Disconnect all device rows.
try {
startAddingDocuments(null);
stopAddingDocuments(null);
} catch (FileNotFoundException exception) {
Log.e(MtpDocumentsProvider.TAG, "Unexpected FileNotFoundException.", exception);
throw new RuntimeException(exception);
}
database.setTransactionSuccessful();
} finally {
database.endTransaction();
}
}
use of android.database.sqlite.SQLiteDatabase in project platform_frameworks_base by android.
the class Mapper method startAddingDocuments.
/**
* Starts adding new documents.
* It changes the direct child documents of the given document from VALID to INVALIDATED.
* Note that it keeps DISCONNECTED documents as they are.
*
* @param parentDocumentId Parent document ID or NULL for root documents.
* @throws FileNotFoundException
*/
void startAddingDocuments(@Nullable String parentDocumentId) throws FileNotFoundException {
final String selection;
final String[] args;
if (parentDocumentId != null) {
selection = COLUMN_PARENT_DOCUMENT_ID + " = ?";
args = strings(parentDocumentId);
} else {
selection = COLUMN_PARENT_DOCUMENT_ID + " IS NULL";
args = EMPTY_ARGS;
}
final SQLiteDatabase database = mDatabase.getSQLiteDatabase();
database.beginTransaction();
try {
getParentOrHaltMapping(parentDocumentId);
Preconditions.checkState(!mInMappingIds.contains(parentDocumentId));
// Set all valid documents as invalidated.
final ContentValues values = new ContentValues();
values.put(COLUMN_ROW_STATE, ROW_STATE_INVALIDATED);
database.update(TABLE_DOCUMENTS, values, selection + " AND " + COLUMN_ROW_STATE + " = ?", DatabaseUtils.appendSelectionArgs(args, strings(ROW_STATE_VALID)));
database.setTransactionSuccessful();
mInMappingIds.add(parentDocumentId);
} finally {
database.endTransaction();
}
}
use of android.database.sqlite.SQLiteDatabase in project platform_frameworks_base by android.
the class AccountManagerService method readPreviousNameInternal.
private String readPreviousNameInternal(UserAccounts accounts, Account account) {
if (account == null) {
return null;
}
synchronized (accounts.cacheLock) {
AtomicReference<String> previousNameRef = accounts.previousNameCache.get(account);
if (previousNameRef == null) {
final SQLiteDatabase db = accounts.openHelper.getReadableDatabase();
Cursor cursor = db.query(TABLE_ACCOUNTS, new String[] { ACCOUNTS_PREVIOUS_NAME }, ACCOUNTS_NAME + "=? AND " + ACCOUNTS_TYPE + "=?", new String[] { account.name, account.type }, null, null, null);
try {
if (cursor.moveToNext()) {
String previousName = cursor.getString(0);
previousNameRef = new AtomicReference<>(previousName);
accounts.previousNameCache.put(account, previousNameRef);
return previousName;
} else {
return null;
}
} finally {
cursor.close();
}
} else {
return previousNameRef.get();
}
}
}
use of android.database.sqlite.SQLiteDatabase in project platform_frameworks_base by android.
the class AccountManagerService method logRecord.
private void logRecord(UserAccounts accounts, String action, String tableName) {
SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
logRecord(db, action, tableName, -1, accounts);
}
use of android.database.sqlite.SQLiteDatabase in project platform_frameworks_base by android.
the class AccountManagerService method logRecordWithUid.
private void logRecordWithUid(UserAccounts accounts, String action, String tableName, int uid) {
SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
logRecord(db, action, tableName, -1, accounts, uid);
}
Aggregations