List of usage examples for android.content ContentValues getAsInteger
public Integer getAsInteger(String key)
From source file:at.bitfire.davdroid.resource.LocalAddressBook.java
@Override public void populate(Resource res) throws LocalStorageException { Contact c = (Contact) res;//from w ww. j av a2 s . co m try { @Cleanup EntityIterator iter = ContactsContract.RawContacts.newEntityIterator( providerClient.query(syncAdapterURI(ContactsContract.RawContactsEntity.CONTENT_URI), null, RawContacts._ID + "=" + c.getLocalID(), null, null)); if (iter.hasNext()) { Entity e = iter.next(); ContentValues values = e.getEntityValues(); c.setUid(values.getAsString(entryColumnUID())); c.unknownProperties = values.getAsString(COLUMN_UNKNOWN_PROPERTIES); c.starred = values.getAsInteger(RawContacts.STARRED) != 0; List<Entity.NamedContentValues> subValues = e.getSubValues(); for (Entity.NamedContentValues subValue : subValues) { values = subValue.values; String mimeType = values.getAsString(ContactsContract.RawContactsEntity.MIMETYPE); switch (mimeType) { case StructuredName.CONTENT_ITEM_TYPE: populateStructuredName(c, values); break; case Phone.CONTENT_ITEM_TYPE: populatePhoneNumber(c, values); break; case Email.CONTENT_ITEM_TYPE: populateEmailAddress(c, values); break; case Photo.CONTENT_ITEM_TYPE: populatePhoto(c, values); break; case Organization.CONTENT_ITEM_TYPE: populateOrganization(c, values); break; case Im.CONTENT_ITEM_TYPE: populateIMPP(c, values); break; case Nickname.CONTENT_ITEM_TYPE: populateNickname(c, values); break; case Note.CONTENT_ITEM_TYPE: populateNote(c, values); break; case StructuredPostal.CONTENT_ITEM_TYPE: populatePostalAddress(c, values); break; case GroupMembership.CONTENT_ITEM_TYPE: populateGroupMembership(c, values); break; case Website.CONTENT_ITEM_TYPE: populateURL(c, values); break; case CommonDataKinds.Event.CONTENT_ITEM_TYPE: populateEvent(c, values); break; case Relation.CONTENT_ITEM_TYPE: populateRelation(c, values); break; case SipAddress.CONTENT_ITEM_TYPE: populateSipAddress(c, values); break; } } } else throw new RecordNotFoundException(); } catch (RemoteException ex) { throw new LocalStorageException(ex); } }
From source file:at.bitfire.vcard4android.AndroidContact.java
protected void populateEmail(ContentValues row) { ezvcard.property.Email email = new ezvcard.property.Email(row.getAsString(Email.ADDRESS)); Integer type = row.getAsInteger(Email.TYPE); if (type != null) switch (type) { case Email.TYPE_HOME: email.addType(EmailType.HOME); break; case Email.TYPE_WORK: email.addType(EmailType.WORK); break; case Email.TYPE_MOBILE: email.addType(Contact.EMAIL_TYPE_MOBILE); break; case Email.TYPE_CUSTOM: String customType = row.getAsString(Email.LABEL); if (!TextUtils.isEmpty(customType)) email.addType(EmailType.get(labelToXName(customType))); }/*from w w w . ja v a2 s . co m*/ if (row.getAsInteger(Email.IS_PRIMARY) != 0) email.setPref(1); contact.getEmails().add(email); }
From source file:com.granita.icloudcalsync.resource.LocalAddressBook.java
@Override public void populate(Resource res) throws LocalStorageException { Contact c = (Contact) res;//from w w w. j a v a 2 s .c o m try { @Cleanup EntityIterator iter = ContactsContract.RawContacts.newEntityIterator( providerClient.query(syncAdapterURI(ContactsContract.RawContactsEntity.CONTENT_URI), null, RawContacts._ID + "=" + c.getLocalID(), null, null)); if (iter.hasNext()) { Entity e = iter.next(); ContentValues values = e.getEntityValues(); c.setUid(values.getAsString(entryColumnUID())); c.setUnknownProperties(values.getAsString(COLUMN_UNKNOWN_PROPERTIES)); c.setStarred(values.getAsInteger(RawContacts.STARRED) != 0); List<Entity.NamedContentValues> subValues = e.getSubValues(); for (Entity.NamedContentValues subValue : subValues) { values = subValue.values; String mimeType = values.getAsString(ContactsContract.RawContactsEntity.MIMETYPE); switch (mimeType) { case StructuredName.CONTENT_ITEM_TYPE: populateStructuredName(c, values); break; case Phone.CONTENT_ITEM_TYPE: populatePhoneNumber(c, values); break; case Email.CONTENT_ITEM_TYPE: populateEmailAddress(c, values); break; case Photo.CONTENT_ITEM_TYPE: populatePhoto(c, values); break; case Organization.CONTENT_ITEM_TYPE: populateOrganization(c, values); break; case Im.CONTENT_ITEM_TYPE: populateIMPP(c, values); break; case Nickname.CONTENT_ITEM_TYPE: populateNickname(c, values); break; case Note.CONTENT_ITEM_TYPE: populateNote(c, values); break; case StructuredPostal.CONTENT_ITEM_TYPE: populatePostalAddress(c, values); break; case GroupMembership.CONTENT_ITEM_TYPE: populateGroupMembership(c, values); break; case Website.CONTENT_ITEM_TYPE: populateURL(c, values); break; case CommonDataKinds.Event.CONTENT_ITEM_TYPE: populateEvent(c, values); break; case Relation.CONTENT_ITEM_TYPE: populateRelation(c, values); break; case SipAddress.CONTENT_ITEM_TYPE: populateSipAddress(c, values); break; } } } else throw new RecordNotFoundException(); } catch (RemoteException ex) { throw new LocalStorageException(ex); } }
From source file:at.bitfire.vcard4android.AndroidContact.java
protected void populateWebsite(ContentValues row) { Url url = new Url(row.getAsString(Website.URL)); if (row.containsKey(Website.TYPE)) switch (row.getAsInteger(Website.TYPE)) { case Website.TYPE_HOMEPAGE: url.setType(Contact.URL_TYPE_HOMEPAGE); break; case Website.TYPE_BLOG: url.setType(Contact.URL_TYPE_BLOG); break; case Website.TYPE_PROFILE: url.setType(Contact.URL_TYPE_PROFILE); break; case Website.TYPE_HOME: url.setType("home"); break; case Website.TYPE_WORK: url.setType("work"); break; case Website.TYPE_FTP: url.setType(Contact.URL_TYPE_FTP); break; case Website.TYPE_CUSTOM: String label = row.getAsString(Website.LABEL); if (!TextUtils.isEmpty(label)) url.setType(labelToXName(label)); break; }/*from ww w .j a va2 s. c om*/ contact.getURLs().add(url); }
From source file:at.bitfire.vcard4android.AndroidContact.java
protected void populatePhoneNumber(ContentValues row) { Telephone number = new Telephone(row.getAsString(Phone.NUMBER)); Integer type = row.getAsInteger(Phone.TYPE); if (type != null) switch (type) { case Phone.TYPE_HOME: number.addType(TelephoneType.HOME); break; case Phone.TYPE_MOBILE: number.addType(TelephoneType.CELL); break; case Phone.TYPE_WORK: number.addType(TelephoneType.WORK); break; case Phone.TYPE_FAX_WORK: number.addType(TelephoneType.FAX); number.addType(TelephoneType.WORK); break; case Phone.TYPE_FAX_HOME: number.addType(TelephoneType.FAX); number.addType(TelephoneType.HOME); break; case Phone.TYPE_PAGER: number.addType(TelephoneType.PAGER); break; case Phone.TYPE_CALLBACK: number.addType(Contact.PHONE_TYPE_CALLBACK); break; case Phone.TYPE_CAR: number.addType(TelephoneType.CAR); break; case Phone.TYPE_COMPANY_MAIN: number.addType(Contact.PHONE_TYPE_COMPANY_MAIN); break; case Phone.TYPE_ISDN: number.addType(TelephoneType.ISDN); break; case Phone.TYPE_MAIN: number.addType(TelephoneType.VOICE); break; case Phone.TYPE_OTHER_FAX: number.addType(TelephoneType.FAX); break; case Phone.TYPE_RADIO: number.addType(Contact.PHONE_TYPE_RADIO); break; case Phone.TYPE_TELEX: number.addType(TelephoneType.TEXTPHONE); break; case Phone.TYPE_TTY_TDD: number.addType(TelephoneType.TEXT); break; case Phone.TYPE_WORK_MOBILE: number.addType(TelephoneType.CELL); number.addType(TelephoneType.WORK); break; case Phone.TYPE_WORK_PAGER: number.addType(TelephoneType.PAGER); number.addType(TelephoneType.WORK); break; case Phone.TYPE_ASSISTANT: number.addType(Contact.PHONE_TYPE_ASSISTANT); break; case Phone.TYPE_MMS: number.addType(Contact.PHONE_TYPE_MMS); break; case Phone.TYPE_CUSTOM: String customType = row.getAsString(CommonDataKinds.Phone.LABEL); if (!TextUtils.isEmpty(customType)) number.addType(TelephoneType.get(labelToXName(customType))); }//w ww. ja v a2 s. co m if (row.getAsInteger(CommonDataKinds.Phone.IS_PRIMARY) != 0) number.setPref(1); contact.getPhoneNumbers().add(number); }
From source file:at.bitfire.vcard4android.AndroidContact.java
protected void populateSipAddress(ContentValues row) { try {//from w w w . j a v a2s. c o m Impp impp = new Impp("sip:" + row.getAsString(SipAddress.SIP_ADDRESS)); if (row.containsKey(SipAddress.TYPE)) switch (row.getAsInteger(SipAddress.TYPE)) { case SipAddress.TYPE_HOME: impp.addType(ImppType.HOME); break; case SipAddress.TYPE_WORK: impp.addType(ImppType.WORK); break; case SipAddress.TYPE_CUSTOM: String customType = row.getAsString(SipAddress.LABEL); if (!TextUtils.isEmpty(customType)) impp.addType(ImppType.get(labelToXName(customType))); } contact.getImpps().add(impp); } catch (IllegalArgumentException e) { Constants.log.warn("Ignoring invalid locally stored SIP address"); } }
From source file:at.bitfire.vcard4android.AndroidContact.java
protected void populateStructuredPostal(ContentValues row) { Address address = new Address(); address.setLabel(row.getAsString(StructuredPostal.FORMATTED_ADDRESS)); if (row.containsKey(StructuredPostal.TYPE)) switch (row.getAsInteger(StructuredPostal.TYPE)) { case StructuredPostal.TYPE_HOME: address.addType(AddressType.HOME); break; case StructuredPostal.TYPE_WORK: address.addType(AddressType.WORK); break; case StructuredPostal.TYPE_CUSTOM: String customType = row.getAsString(StructuredPostal.LABEL); if (!TextUtils.isEmpty(customType)) address.addType(AddressType.get(labelToXName(customType))); break; }//w w w .j a v a 2 s. c o m address.setStreetAddress(row.getAsString(StructuredPostal.STREET)); address.setPoBox(row.getAsString(StructuredPostal.POBOX)); address.setExtendedAddress(row.getAsString(StructuredPostal.NEIGHBORHOOD)); address.setLocality(row.getAsString(StructuredPostal.CITY)); address.setRegion(row.getAsString(StructuredPostal.REGION)); address.setPostalCode(row.getAsString(StructuredPostal.POSTCODE)); address.setCountry(row.getAsString(StructuredPostal.COUNTRY)); contact.getAddresses().add(address); }
From source file:at.bitfire.vcard4android.AndroidContact.java
protected void populateNickname(ContentValues row) { if (row.containsKey(Nickname.NAME)) { ezvcard.property.Nickname nick = new ezvcard.property.Nickname(); nick.addValue(row.getAsString(Nickname.NAME)); Integer type = row.getAsInteger(Nickname.TYPE); if (type != null) switch (type) { case Nickname.TYPE_MAIDEN_NAME: nick.setType(Contact.NICKNAME_TYPE_MAIDEN_NAME); break; case Nickname.TYPE_SHORT_NAME: nick.setType(Contact.NICKNAME_TYPE_SHORT_NAME); break; case Nickname.TYPE_INITIALS: nick.setType(Contact.NICKNAME_TYPE_INITIALS); break; case Nickname.TYPE_OTHER_NAME: nick.setType(Contact.NICKNAME_TYPE_OTHER_NAME); break; case Nickname.TYPE_CUSTOM: String label = row.getAsString(Nickname.LABEL); if (!TextUtils.isEmpty(label)) nick.setType(labelToXName(label)); }// ww w.j av a 2s.co m contact.nickName = nick; } }
From source file:com.homeworkreminder.Main.java
protected static void clearAll() { List<ContentValues> alarms = Database.queryAlarmList(); for (ContentValues v : alarms) { scheduleClient.cancelAlarm(v.getAsInteger("original_id")); }//w ww .jav a 2 s. c om alarmHandler.cancelAllDisplayingNotifications(); Upcoming.clear(); TaskHolder.clear(); TaskMap.clear(); SubjectMap.clear(); subjectArray.clear(); Database.deleteAll(); Database.deleteAllSubjects(); Database.deleteAllAlarms(); subjectArray.add(DEFAULT_SUBJECT); generateSubjectMap(); generateTaskMap(TaskHolder); // updateListView(true); }
From source file:org.runnerup.view.DetailActivity.java
void requery() { {/*from w w w. java 2 s . co m*/ /** * Laps */ String[] from = new String[] { "_id", DB.LAP.LAP, DB.LAP.INTENSITY, DB.LAP.TIME, DB.LAP.DISTANCE, DB.LAP.PLANNED_TIME, DB.LAP.PLANNED_DISTANCE, DB.LAP.PLANNED_PACE, DB.LAP.AVG_HR }; Cursor c = mDB.query(DB.LAP.TABLE, from, DB.LAP.ACTIVITY + " == " + mID, null, null, null, "_id", null); laps = DBHelper.toArray(c); c.close(); lapHrPresent = false; for (ContentValues v : laps) { if (v.containsKey(DB.LAP.AVG_HR) && v.getAsInteger(DB.LAP.AVG_HR) > 0) { lapHrPresent = true; break; } } } { /** * Accounts/reports */ String sql = new String("SELECT DISTINCT " + " acc._id, " // 0 + (" acc." + DB.ACCOUNT.NAME + ", ") + (" acc." + DB.ACCOUNT.DESCRIPTION + ", ") + (" acc." + DB.ACCOUNT.FLAGS + ", ") + (" acc." + DB.ACCOUNT.AUTH_METHOD + ", ") + (" acc." + DB.ACCOUNT.AUTH_CONFIG + ", ") + (" acc." + DB.ACCOUNT.ENABLED + ", ") + (" rep._id as repid, ") + (" rep." + DB.EXPORT.ACCOUNT + ", ") + (" rep." + DB.EXPORT.ACTIVITY + ", ") + (" rep." + DB.EXPORT.STATUS) + (" FROM " + DB.ACCOUNT.TABLE + " acc ") + (" LEFT OUTER JOIN " + DB.EXPORT.TABLE + " rep ") + (" ON ( acc._id = rep." + DB.EXPORT.ACCOUNT) + (" AND rep." + DB.EXPORT.ACTIVITY + " = " + mID + " )") + (" WHERE acc." + DB.ACCOUNT.ENABLED + " != 0 ") + (" AND acc." + DB.ACCOUNT.AUTH_CONFIG + " is not null")); Cursor c = mDB.rawQuery(sql, null); alreadyUploadedUploaders.clear(); pendingUploaders.clear(); reports.clear(); if (c.moveToFirst()) { do { ContentValues tmp = DBHelper.get(c); Uploader uploader = uploadManager.add(tmp); if (!uploader.checkSupport(Feature.UPLOAD)) { continue; } reports.add(tmp); if (tmp.containsKey("repid")) { alreadyUploadedUploaders.add(tmp.getAsString(DB.ACCOUNT.NAME)); } else if (tmp.containsKey(DB.ACCOUNT.FLAGS) && Bitfield.test(tmp.getAsLong(DB.ACCOUNT.FLAGS), DB.ACCOUNT.FLAG_UPLOAD)) { pendingUploaders.add(tmp.getAsString(DB.ACCOUNT.NAME)); } } while (c.moveToNext()); } c.close(); } if (mode == MODE_DETAILS) { if (pendingUploaders.isEmpty()) { uploadButton.setVisibility(View.GONE); } else { uploadButton.setVisibility(View.VISIBLE); } } for (BaseAdapter a : adapters) { a.notifyDataSetChanged(); } }