本文整理匯總了Java中android.database.sqlite.SQLiteStatement.close方法的典型用法代碼示例。如果您正苦於以下問題:Java SQLiteStatement.close方法的具體用法?Java SQLiteStatement.close怎麽用?Java SQLiteStatement.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.database.sqlite.SQLiteStatement
的用法示例。
在下文中一共展示了SQLiteStatement.close方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: performGetLength
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
private long performGetLength() {
SQLiteDatabase database = mDatabaseSupplier.getDatabase();
if (database == null) {
return 0;
}
String sql = "SELECT count(" + WXSQLiteOpenHelper.COLUMN_KEY + ") FROM " + WXSQLiteOpenHelper.TABLE_STORAGE;
SQLiteStatement statement = null;
try {
statement = database.compileStatement(sql);
return statement.simpleQueryForLong();
} catch (Exception e) {
WXLogUtils.e(WXSQLiteOpenHelper.TAG_STORAGE, "DefaultWXStorage occurred an exception when execute getLength:" + e.getMessage());
return 0;
} finally {
if(statement != null) {
statement.close();
}
}
}
示例2: updateItemActiveness
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void updateItemActiveness(int itemId, boolean active)
{
Log.d(L.TAG, "Setting active property of " + itemId + " to " + active);
//long t = System.currentTimeMillis();
SQLiteDatabase db = helper.getWritableDatabase();
//long t2 = System.currentTimeMillis();
//Log.d(TAG, "Open DB took " + ((t2-t)/1000.0));
//t = t2;
SQLiteStatement stmt = db.compileStatement("update items set active=? where id=?");
stmt.bindLong(1, active?1:0);
stmt.bindLong(2, itemId);
//t2 = System.currentTimeMillis();
//Log.d(TAG, "stmt creation took " + ((t2-t)/1000.0));
//t = t2;
stmt.execute();
//t2 = System.currentTimeMillis();
//Log.d(TAG, "execute() took " + ((t2-t)/1000.0));
//t = t2;
stmt.close();
db.close();
//t2 = System.currentTimeMillis();
//Log.d(TAG, "close() took " + ((t2-t)/1000.0));
//t = t2;
}
示例3: deleteList
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void deleteList(int list_id)
{
Log.d(L.TAG, "Deleting list " + list_id);
SQLiteDatabase db = helper.getWritableDatabase();
SQLiteStatement stmt = db.compileStatement("delete from items where list_id=?");
stmt.bindLong(1, list_id);
stmt.execute();
stmt.close();
SQLiteStatement stmt2 = db.compileStatement("delete from lists where id=?");
stmt2.bindLong(1, list_id);
stmt2.execute();
stmt2.close();
db.close();
}
示例4: performSetItem
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
private boolean performSetItem(String key, String value, boolean isPersistent, boolean allowRetryWhenFull) {
SQLiteDatabase database = mDatabaseSupplier.getDatabase();
if (database == null) {
return false;
}
WXLogUtils.d(WXSQLiteOpenHelper.TAG_STORAGE, "set k-v to storage(key:" + key + ",value:" + value + ",isPersistent:" + isPersistent + ",allowRetry:" + allowRetryWhenFull + ")");
String sql = "INSERT OR REPLACE INTO " + WXSQLiteOpenHelper.TABLE_STORAGE + " VALUES (?,?,?,?);";
SQLiteStatement statement = null;
String timeStamp = WXSQLiteOpenHelper.sDateFormatter.format(new Date());
try {
statement = database.compileStatement(sql);
statement.clearBindings();
statement.bindString(1, key);
statement.bindString(2, value);
statement.bindString(3, timeStamp);
statement.bindLong(4, isPersistent ? 1 : 0);
statement.execute();
return true;
} catch (Exception e) {
WXLogUtils.e(WXSQLiteOpenHelper.TAG_STORAGE, "DefaultWXStorage occurred an exception when execute setItem :" + e.getMessage());
if (e instanceof SQLiteFullException) {
if (allowRetryWhenFull && trimToSize()) {
//try again
//setItem/setItemPersistent method only allow try once when occurred a sqliteFullException.
WXLogUtils.d(WXSQLiteOpenHelper.TAG_STORAGE, "retry set k-v to storage(key:" + key + ",value:" + value + ")");
return performSetItem(key, value, isPersistent, false);
}
}
return false;
} finally {
if(statement != null) {
statement.close();
}
}
}
示例5: convertShortcutsToLauncherActivities
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
/**
* Replaces all shortcuts of type {@link Favorites#ITEM_TYPE_SHORTCUT} which have a valid
* launcher activity target with {@link Favorites#ITEM_TYPE_APPLICATION}.
*/
@Thunk void convertShortcutsToLauncherActivities(SQLiteDatabase db) {
db.beginTransaction();
Cursor c = null;
SQLiteStatement updateStmt = null;
try {
// Only consider the primary user as other users can't have a shortcut.
long userSerial = getDefaultUserSerial();
c = db.query(Favorites.TABLE_NAME, new String[] {
Favorites._ID,
Favorites.INTENT,
}, "itemType=" + Favorites.ITEM_TYPE_SHORTCUT + " AND profileId=" + userSerial,
null, null, null, null);
updateStmt = db.compileStatement("UPDATE favorites SET itemType="
+ Favorites.ITEM_TYPE_APPLICATION + " WHERE _id=?");
final int idIndex = c.getColumnIndexOrThrow(Favorites._ID);
final int intentIndex = c.getColumnIndexOrThrow(Favorites.INTENT);
while (c.moveToNext()) {
String intentDescription = c.getString(intentIndex);
Intent intent;
try {
intent = Intent.parseUri(intentDescription, 0);
} catch (URISyntaxException e) {
e.printStackTrace();
continue;
}
if (!Utilities.isLauncherAppTarget(intent)) {
continue;
}
long id = c.getLong(idIndex);
updateStmt.bindLong(1, id);
updateStmt.executeUpdateDelete();
}
db.setTransactionSuccessful();
} catch (SQLException ex) {
ex.printStackTrace();
} finally {
db.endTransaction();
if (c != null) {
c.close();
}
if (updateStmt != null) {
updateStmt.close();
}
}
}
示例6: close
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
void close(SQLiteStatement sqLiteStatement)
{
if (sqLiteStatement != null)
{
try
{
sqLiteStatement.close();
} catch (Exception e)
{
e.printStackTrace();
}
}
}
示例7: countInactiveItemsInList
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
private int countInactiveItemsInList(SQLiteDatabase db, int listId)
{
SQLiteStatement stmt = db.compileStatement("select count(*) from items where list_id=? and active=1");
stmt.bindLong(1, listId);
int rv = (int)stmt.simpleQueryForLong();
stmt.close();
return rv;
}
示例8: InsertToSqlite
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void InsertToSqlite(String imei, String latitude, String longitude, String out)
{
SQLiteStatement statement = localdb.compileStatement("INSERT INTO position VALUES(?,?,?,datetime(),?)");
statement.bindString(1, imei);
statement.bindString(2, latitude);
statement.bindString(3, longitude);
statement.bindString(4, out);
statement.executeInsert();
statement.close();
}
示例9: longForQuery
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
/**
* Utility method to run the query on the db and return the value in the
* first column of the first row.
*/
public static long longForQuery(ShadowSQLiteDatabase db, String query, String[] selectionArgs) {
SQLiteStatement prog = db.compileStatement(query);
try {
return longForQuery(prog, selectionArgs);
} finally {
prog.close();
}
}
示例10: stringForQuery
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
/**
* Utility method to run the query on the db and return the value in the
* first column of the first row.
*/
public static String stringForQuery(SQLiteDatabase db, String query, String[] selectionArgs) {
SQLiteStatement prog = db.compileStatement(query);
try {
return stringForQuery(prog, selectionArgs);
} finally {
prog.close();
}
}
示例11: blobFileDescriptorForQuery
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
/**
* Utility method to run the query on the db and return the blob value in the
* first column of the first row.
*
* @return A read-only file descriptor for a copy of the blob value.
*/
public static ParcelFileDescriptor blobFileDescriptorForQuery(SQLiteDatabase db,
String query, String[] selectionArgs) {
SQLiteStatement prog = db.compileStatement(query);
try {
return blobFileDescriptorForQuery(prog, selectionArgs);
} finally {
prog.close();
}
}
示例12: countItemsInList
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
private int countItemsInList(SQLiteDatabase db, int listId)
{
SQLiteStatement stmt = db.compileStatement("select count(*) from items where list_id=?");
stmt.bindLong(1, listId);
int rv = (int)stmt.simpleQueryForLong();
stmt.close();
return rv;
}
示例13: updateListLabel
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void updateListLabel(int listId, String newLabel)
{
Log.d(L.TAG, "Updating label of list " + listId + " to " + newLabel);
SQLiteDatabase db = helper.getWritableDatabase();
SQLiteStatement stmt = db.compileStatement("update lists set label=? where id=?");
stmt.bindString(1, newLabel);
stmt.bindLong(2, listId);
stmt.execute();
stmt.close();
db.close();
}
示例14: createList
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void createList(String label)
{
Log.d(L.TAG, "Insert list " + label);
SQLiteDatabase db = helper.getWritableDatabase();
SQLiteStatement stmt = db.compileStatement("insert into lists (label) values (?)");
stmt.bindString(1, label);
stmt.executeInsert();
stmt.close();
db.close();
}
示例15: deleteInactive
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void deleteInactive(int list_id)
{
Log.d(L.TAG, "Deleting inactive items from list " + list_id);
SQLiteDatabase db = helper.getWritableDatabase();
SQLiteStatement stmt = db.compileStatement("delete from items where list_id=? and active=0");
stmt.bindLong(1, list_id);
stmt.execute();
stmt.close();
db.close();
}