List of usage examples for android.database Cursor close
void close();
From source file:com.android.emailcommon.provider.Account.java
public static Account restoreAccountWithAddress(Context context, String emailAddress, ContentObserver observer) {//from w w w. jav a2 s. c o m final Cursor c = context.getContentResolver().query(CONTENT_URI, new String[] { AccountColumns._ID }, AccountColumns.EMAIL_ADDRESS + "=?", new String[] { emailAddress }, null); try { if (c == null || !c.moveToFirst()) { return null; } final long id = c.getLong(c.getColumnIndex(AccountColumns._ID)); return restoreAccountWithId(context, id, observer); } finally { if (c != null) { c.close(); } } }
From source file:com.github.gw2app.events.Gw2ApiEvents.java
private boolean _hasMapNamesInDB() { SQLiteDatabase db = this.dbhelper.getReadableDatabase(); Cursor cursor; if (db != null) { cursor = db.query(Gw2DB.MAP_NAMES_TABLE, null, null, null, null, null, null); if (cursor.getCount() == 0) { cursor.close(); return false; } else {//from w w w . j a va 2 s .co m cursor.close(); return true; } } return false; }
From source file:com.jaspersoft.android.jaspermobile.test.acceptance.profile.ServersManagerPageTest.java
public void testValidFormCreation() { startActivityUnderTest();/*from w ww .j a va 2 s. com*/ onView(withId(R.id.addProfile)).perform(click()); onView(withText(R.string.sp_bc_add_profile)).check(matches(isDisplayed())); onView(withId(R.id.aliasEdit)).perform(typeText(DatabaseUtils.TEST_ALIAS)); onView(withId(R.id.serverUrlEdit)).perform(typeText(DatabaseUtils.TEST_SERVER_URL)); onView(withId(R.id.organizationEdit)).perform(typeText(DatabaseUtils.TEST_ORGANIZATION)); onView(withId(R.id.usernameEdit)).perform(typeText(DatabaseUtils.TEST_USERNAME)); onView(withId(R.id.passwordEdit)).perform(typeText(DatabaseUtils.TEST_PASS)); onView(withId(R.id.saveAction)).perform(click()); Cursor cursor = queryTestProfile(mApplication.getContentResolver()); try { assertThat(cursor.getCount(), is(1)); } finally { cursor.close(); } }
From source file:com.github.gw2app.events.Gw2ApiEvents.java
private boolean _hasWorldNamesInDB() { SQLiteDatabase db = this.dbhelper.getReadableDatabase(); Cursor cursor; if (db != null) { cursor = db.query(Gw2DB.WORLD_NAMES_TABLE, null, null, null, null, null, null); if (cursor.getCount() == 0) { cursor.close(); return false; } else {// www . j av a 2 s .co m cursor.close(); return true; } } return false; }
From source file:com.gmail.emerssso.srbase.EditSRActivity.java
/** * Fill data from the database into the form. * * @param uri the uri of the database entry to load *//*from ww w. ja v a 2 s .c o m*/ private void fillData(Uri uri) { String[] projection = { SRTable.COLUMN_CUSTOMER_NAME, SRTable.COLUMN_DESCRIPTION, SRTable.COLUMN_MODEL_NUMBER, SRTable.COLUMN_SERIAL_NUMBER, SRTable.COLUMN_SR_NUMBER, SRTable.COLUMN_ID, SRTable.COLUMN_BUSINESS_NAME }; Cursor cursor = getContentResolver().query(uri, projection, null, null, null); if (cursor != null) { cursor.moveToFirst(); SR sr = SR.fromCursor(cursor); cursor.close(); mSRNumber.setText(sr.getNumber()); mCustomer.setText(sr.getCustomerName()); mBusinessName.setText(sr.getBusinessName()); mModelNumber.setText(sr.getModelNumber()); mSerialNumber.setText(sr.getSerialNumber()); mDescription.setText(sr.getDescription()); } }
From source file:com.googlecode.android_scripting.facade.ContactsFacade.java
@Rpc(description = "Returns the number of contacts.") public Integer contactsGetCount() { Integer result = 0;//from w w w . j a va 2 s . c o m Cursor cursor = mContentResolver.query(CONTACTS_URI, null, null, null, null); if (cursor != null) { result = cursor.getCount(); cursor.close(); } return result; }
From source file:com.jaspersoft.android.jaspermobile.util.SavedItemHelper.java
private String getExtension(Uri recordUri) { Cursor cursor = context.getContentResolver().query(recordUri, null, null, null, null); if (cursor == null || !cursor.moveToFirst()) return null; String extension = cursor.getString(cursor.getColumnIndex(SavedItemsTable.FILE_FORMAT)); cursor.close(); return extension; }
From source file:com.jaspersoft.android.jaspermobile.util.SavedItemHelper.java
private File getFile(Uri recordUri) { Cursor cursor = context.getContentResolver().query(recordUri, null, null, null, null); if (cursor == null || !cursor.moveToFirst()) return null; File file = new File(cursor.getString(cursor.getColumnIndex(SavedItemsTable.FILE_PATH))); cursor.close(); return file;/* w ww . j a va 2 s . co m*/ }
From source file:ru.gkpromtech.exhibition.db.DbHelper.java
public String getPragma(SQLiteDatabase db, String pragma) { String value = null;//from ww w . j a va2 s.c om Cursor cursor = db.rawQuery("PRAGMA " + pragma, null); if (cursor.moveToNext()) value = cursor.getString(0); cursor.close(); return value; }
From source file:de.golov.zeitgeistreich.ZeitGeistReichActivity.java
protected void submitImage(String tags) { Intent intent = getIntent();/*from w w w .j ava2 s .co m*/ Bundle extras = intent.getExtras(); Uri mImageUri = null; File mFilename = null; if (Intent.ACTION_SEND.equals(intent.getAction()) && extras != null) { if (extras.containsKey(Intent.EXTRA_STREAM)) { mImageUri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM); if (mImageUri != null) { Cursor cursor = getContentResolver().query(mImageUri, null, null, null, null); if (cursor.moveToFirst()) { mFilename = new File(cursor.getString(cursor.getColumnIndexOrThrow(ImageColumns.DATA))); } cursor.close(); if (mFilename != null) { ZeitGeistReichUploaderTask task = new ZeitGeistReichUploaderTask(); ZeitGeistObject o = new ZeitGeistObject(mFilename, tags); task.execute(o); } } } } }