本文整理汇总了C++中SQLiteDatabase::close方法的典型用法代码示例。如果您正苦于以下问题:C++ SQLiteDatabase::close方法的具体用法?C++ SQLiteDatabase::close怎么用?C++ SQLiteDatabase::close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLiteDatabase
的用法示例。
在下文中一共展示了SQLiteDatabase::close方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: maybeLoadPermanentPermissions
void GeolocationPermissions::maybeLoadPermanentPermissions()
{
if (s_permanentPermissionsLoaded)
return;
s_permanentPermissionsLoaded = true;
SQLiteDatabase database;
if (!database.open(s_databasePath + databaseName))
return;
// Create the table here, such that even if we've just created the DB, the
// commands below should succeed.
if (!database.executeCommand("CREATE TABLE IF NOT EXISTS Permissions (origin TEXT UNIQUE NOT NULL, allow INTEGER NOT NULL)")) {
database.close();
return;
}
SQLiteStatement statement(database, "SELECT * FROM Permissions");
if (statement.prepare() != SQLResultOk) {
database.close();
return;
}
ASSERT(s_permanentPermissions.size() == 0);
while (statement.step() == SQLResultRow)
s_permanentPermissions.set(statement.getColumnText(0), statement.getColumnInt64(1));
database.close();
}
示例2: maybeStorePermanentPermissions
void NotificationPresenterImpl::maybeStorePermanentPermissions()
{
// If the permanent permissions haven't been modified, there's no need to
// save them to the DB. (If we haven't even loaded them, writing them now
// would overwrite the stored permissions with the empty set.)
SQLiteDatabase database;
if (!openDatabase(&database))
return;
SQLiteTransaction transaction(database);
// The number of entries should be small enough that it's not worth trying
// to perform a diff. Simply clear the table and repopulate it.
if (!database.executeCommand("DELETE FROM NotifyPermissions")) {
database.close();
return;
}
PermissionsMap::const_iterator end = s_notificationPermissions.end();
for (PermissionsMap::const_iterator iter = s_notificationPermissions.begin(); iter != end; ++iter) {
SQLiteStatement statement(database, "INSERT INTO NotifyPermissions (origin, allow) VALUES (?, ?)");
if (statement.prepare() != SQLResultOk)
continue;
statement.bindText(1, iter->first);
statement.bindInt64(2, iter->second);
statement.executeCommand();
}
transaction.commit();
database.close();
}
示例3: maybeLoadPermanentPermissions
void NotificationPresenterImpl::maybeLoadPermanentPermissions()
{
SQLiteDatabase database;
if (!openDatabase(&database))
return;
LOGV("NotificationPresenterImpl::maybeLoadPermanentPermissions");
// Create the table here, such that even if we've just created the DB, the
// commands below should succeed.
if (!database.executeCommand("CREATE TABLE IF NOT EXISTS NotifyPermissions (origin TEXT UNIQUE NOT NULL, allow INTEGER NOT NULL)")) {
LOGV("NotificationPresenterImpl::maybeLoadPermanentPermissions inside fail create table");
database.close();
return;
}
SQLiteStatement statement(database, "SELECT * FROM NotifyPermissions");
if (statement.prepare() != SQLResultOk) {
database.close();
return;
}
ASSERT(s_notificationPermissions.size() == 0);
while (statement.step() == SQLResultRow)
s_notificationPermissions.set(statement.getColumnText(0), statement.getColumnInt64(1));
database.close();
}
示例4: test
// A test function.
void SQLiteDatabase::test()
{
// Sample usage code follows...
std::string strFileName = "sqlite3.txt";
SQLiteDatabase db;
try {
Verbose::out(1, "*");
Verbose::out(1, "Create/Open database: sqlite3.txt");
db.open(strFileName);
SQLiteRecordset rset(db);
Verbose::out(1, "create table Test1 (Id int primary key, Name varchar(255))");
db.execute("create table Test1 (Id int primary key, Name varchar(255))");
Verbose::out(2, "create table Test1 (Id int primary key, Name varchar(255))");
db.execute("create table Test2 (Id int primary key, Name varchar(255))");
Verbose::out(1, "Begin transaction...");
db.beginTransaction();
for (int iIndex = 1; (iIndex < 10); iIndex++)
{
std::string strSQL = "insert into Test1 values (" + ::getInt(iIndex) + ", 'Test1-" + ::getInt(iIndex) + "')";
Verbose::out(1, "\t" + strSQL);
db.execute(strSQL);
}
for (int iIndex = 1; (iIndex < 10); iIndex++)
{
std::string strSQL = "insert into Test2 values (" + ::getInt(iIndex) + ", 'Test2-" + ::getInt(iIndex) + "')";
Verbose::out(1, "\t" + strSQL);
db.execute(strSQL);
}
Verbose::out(1, "Commit transaction...");
db.commitTransaction();
Verbose::out(1, "select Test1.id, Test1.Name, Test2.Name from Test1, Test2 where Test1.Id = Test2.id");
rset.open("select Test1.id, Test1.Name, Test2.Name from Test1, Test2 where Test1.Id = Test2.id");
while (rset.fetch())
{
int iID = rset.getInteger(0);
std::string strName = rset.getString(1);
std::string strName2 = rset.getString(2);
Verbose::out(1, "\tfetched: " + ::getInt(iID) + ", " + strName + ", " + strName2);
}
rset.close();
Verbose::out(1, "drop table Test1");
db.execute("drop table Test1");
Verbose::out(1, "drop table Test2");
db.execute("drop table Test2");
Verbose::out(1, "Closing SQLite database");
db.close();
Verbose::out(1, "*");
} catch (SQLiteException& e) {db.rollbackTransaction(); db.close(); Verbose::out(1, e.getMessage());}
// End sample usage code
}
示例5: deleteDatabase
void NotificationPresenterImpl::deleteDatabase()
{
LOGV("NotificationPresenterImpl::clearAll");
SQLiteDatabase database;
if (!openDatabase(&database))
return;
SQLiteTransaction transaction(database);
if (!database.executeCommand("DELETE FROM NotifyPermissions")) {
database.close();
return;
}
transaction.commit();
database.close();
}