List of usage examples for android.content ContentValues getAsString
public String getAsString(String key)
From source file:com.granita.icloudcalsync.resource.LocalAddressBook.java
@Override public void populate(Resource res) throws LocalStorageException { Contact c = (Contact) res;/*w w w .j av a 2 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.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.davdroid.resource.LocalAddressBook.java
protected void populateNickname(Contact c, ContentValues row) { // TYPE (maiden name, short name, ) and LABEL are not processed here because Contacts app doesn't support it c.nickName = row.getAsString(Nickname.NAME); }
From source file:com.granita.icloudcalsync.resource.LocalAddressBook.java
protected void populateNickname(Contact c, ContentValues row) { // TYPE (maiden name, short name, ) and LABEL are not processed here because Contacts app doesn't support it c.setNickName(row.getAsString(Nickname.NAME)); }
From source file:at.bitfire.davdroid.resource.LocalAddressBook.java
protected void populatePhoneNumber(Contact c, ContentValues row) { ezvcard.property.Telephone number = new ezvcard.property.Telephone(row.getAsString(Phone.NUMBER)); switch (row.getAsInteger(Phone.TYPE)) { case Phone.TYPE_HOME: number.addType(TelephoneType.HOME); break;/*from w w w .j av a 2 s .co m*/ 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.PREF); 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(Phone.LABEL); if (StringUtils.isNotEmpty(customType)) number.addType(TelephoneType.get(labelToXName(customType))); } if (row.getAsInteger(Phone.IS_PRIMARY) != 0) number.addType(TelephoneType.PREF); c.getPhoneNumbers().add(number); }
From source file:at.bitfire.vcard4android.AndroidContact.java
protected void populateContact(ContentValues row) { fileName = row.getAsString(COLUMN_FILENAME); eTag = row.getAsString(COLUMN_ETAG); contact.uid = row.getAsString(COLUMN_UID); }
From source file:at.bitfire.davdroid.resource.LocalAddressBook.java
protected void populateEvent(Contact c, ContentValues row) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", Locale.US); try {/*from w w w . j a v a 2s . c o m*/ Date date = formatter.parse(row.getAsString(CommonDataKinds.Event.START_DATE)); switch (row.getAsInteger(CommonDataKinds.Event.TYPE)) { case CommonDataKinds.Event.TYPE_ANNIVERSARY: c.anniversary = new Anniversary(date); break; case CommonDataKinds.Event.TYPE_BIRTHDAY: c.birthDay = new Birthday(date); break; } } catch (ParseException e) { Log.w(TAG, "Couldn't parse local birthday/anniversary date", e); } }
From source file:at.bitfire.vcard4android.AndroidContact.java
protected void populateNote(ContentValues row) { contact.note = row.getAsString(Note.NOTE); }
From source file:edu.cens.loci.ui.PlaceViewActivity.java
/** * Build up the entries to display on the screen. * * @param personCursor the URI for the contact being displayed *//*from ww w .j a v a 2s . c o m*/ private final void buildEntries() { final Context context = this; final Sources sources = Sources.getInstance(context); ArrayList<ViewEntry> items = new ArrayList<ViewEntry>(); int typeIcon = R.drawable.icon_question; String typeString = "Unknown"; if (mPlace.type == Places.TYPE_GPS) { typeIcon = R.drawable.icon_satellite; typeString = "GPS"; } else if (mPlace.type == Places.TYPE_WIFI) { typeIcon = R.drawable.icon_wifi; typeString = "Wi-Fi"; } // detection type items.add(new ViewEntry(LIST_ACTION_NO_ACTION, typeIcon, "Dectection Sensor", typeString, null)); // recent visit time String recentVisitTime = getRecentVisitSubstring(); //"May 4, 3:00pm, 1hr"; items.add(new ViewEntry(LIST_ACTION_VIEW_VISITS, R.drawable.ic_clock_strip_desk_clock, "View recent visits", recentVisitTime, null)); for (Entity entity : mEntities) { final ContentValues entValues = entity.getEntityValues(); final String accountType = entValues.getAsString(Places.ACCOUNT_TYPE); final long placeId = entValues.getAsLong(Places._ID); for (NamedContentValues subValue : entity.getSubValues()) { final ContentValues entryValues = subValue.values; entryValues.put(Places.Data.PLACE_ID, placeId); final long dataId = entryValues.getAsLong(Data._ID); final String mimeType = entryValues.getAsString(Data.MIMETYPE); if (mimeType == null) continue; final DataKind kind = sources.getKindOrFallback(accountType, mimeType, this, PlacesSource.LEVEL_MIMETYPES); if (kind == null) continue; //Log.e(TAG, "buildEntries: dataId=" + dataId + ", mimeType=" + mimeType); // public ViewEntry(int action, int icon, String text, String subtext, Intent intent) { if (WifiFingerprint.CONTENT_ITEM_TYPE.equals(mimeType)) { String fingerprint = entryValues.getAsString(WifiFingerprint.FINGERPRINT); long timestamp = entryValues.getAsLong(WifiFingerprint.TIMESTAMP); String subtext = "Captured at " + MyDateUtils.getAbrv_MMM_d_h_m(timestamp); //Log.d(TAG, fingerprint); //String apsAbstract = getWifiInfoSubstring(5, fingerprint); ViewEntry item = new ViewEntry(LIST_ACTION_VIEW_WIFIS, R.drawable.ic_settings_wireless, "View Wi-Fi APs", subtext, null); item.extra_string = fingerprint; mWifiEntries.add(item); } else if (GpsCircleArea.CONTENT_ITEM_TYPE.equals(mimeType)) { double lat = entryValues.getAsDouble(GpsCircleArea.LATITUDE); double lon = entryValues.getAsDouble(GpsCircleArea.LONGITUDE); float rad = entryValues.getAsFloat(GpsCircleArea.RADIUS); //Log.d(TAG, "lat=" + lat + ",lon=" + lon + ",rad=" + rad); ViewEntry item = new ViewEntry(-1, -1, null, null, null); item.extra_double1 = lat; item.extra_double2 = lon; item.extra_float1 = rad; mGpsEntries.add(item); } else if (StructuredPostal.CONTENT_ITEM_TYPE.equals(mimeType)) { ViewEntry item = ViewEntry.fromValues(context, mimeType, kind, placeId, dataId, entryValues); String uri = "geo:0,0?q=" + TextUtils.htmlEncode(item.data); item.intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); item.action = LIST_ACTION_POSTAL; item.text = item.label; item.subtext = item.data; mPostalEntries.add(item); } else if (Keyword.CONTENT_ITEM_TYPE.equals(mimeType)) { ViewEntry item = ViewEntry.fromValues(context, mimeType, kind, placeId, dataId, entryValues); item.text = item.data; item.subtext = null; mTagEntries.add(item); } else if (Note.CONTENT_ITEM_TYPE.equals(mimeType)) { ViewEntry item = ViewEntry.fromValues(context, mimeType, kind, placeId, dataId, entryValues); item.text = item.label; item.subtext = item.data; mOtherEntries.add(item); } else if (Website.CONTENT_ITEM_TYPE.equals(mimeType)) { ViewEntry item = ViewEntry.fromValues(context, mimeType, kind, placeId, dataId, entryValues); item.uri = null; item.action = LIST_ACTION_WEBSITE; item.text = item.label; item.subtext = item.data; item.intent = new Intent(Intent.ACTION_VIEW, Uri.parse(item.data)); mWebsiteEntries.add(item); } } } for (ViewEntry item : mWifiEntries) { items.add(item); } mWifiEntries.clear(); for (ViewEntry item : mPostalEntries) { items.add(item); } mPostalEntries.clear(); for (ViewEntry item : mTagEntries) { items.add(item); } mTagEntries.clear(); for (ViewEntry item : mWebsiteEntries) { items.add(item); } mWebsiteEntries.clear(); for (ViewEntry item : mOtherEntries) { items.add(item); } mOtherEntries.clear(); // Log.d(TAG, "size of items = " + items.size()); ViewEntryAdapter adapter = new ViewEntryAdapter(this, R.layout.place_view_list_item, items); mListView.setAdapter(adapter); }
From source file:export.UploadManager.java
@SuppressWarnings("null") public Uploader add(ContentValues config) { if (config == null) { System.err.println("Add null!"); //assert (false); return null; }/* w ww . j a va 2 s . c o m*/ String uploaderName = config.getAsString(Constants.DB.ACCOUNT.NAME); if (uploaderName == null) { System.err.println("name not found!"); return null; } if (uploaders.containsKey(uploaderName)) { return uploaders.get(uploaderName); } Uploader uploader = null; //if (uploaderName.contentEquals(RunKeeperUploader.NAME)) { // uploader = new RunKeeperUploader(this); if (uploaderName.contentEquals(GarminUploader.NAME)) { uploader = new GarminUploader(this); //} else if (uploaderName.contentEquals(FunBeatUploader.NAME)) { // uploader = new FunBeatUploader(this); } else if (uploaderName.contentEquals(MapMyRunUploader.NAME)) { uploader = new MapMyRunUploader(this); } else if (uploaderName.contentEquals(NikePlus.NAME)) { uploader = new NikePlus(this); //} else if (uploaderName.contentEquals(JoggSE.NAME)) { // uploader = new JoggSE(this); // } else if (uploaderName.contentEquals(Endomondo.NAME)) { // uploader = new Endomondo(this); //} else if (uploaderName.contentEquals(RunningAHEAD.NAME)) { // uploader = new RunningAHEAD(this); //} else if (uploaderName.contentEquals(RunnerUpLive.NAME)) { // uploader = new RunnerUpLive(this); // } else if (uploaderName.contentEquals(DigifitUploader.NAME)) { // uploader = new DigifitUploader(this); } else if (uploaderName.contentEquals(Strava.NAME)) { uploader = new Strava(this); } else if (uploaderName.contentEquals(Facebook.NAME)) { uploader = new Facebook(context, this); } else if (uploaderName.contentEquals(GooglePlus.NAME)) { uploader = new GooglePlus(this); } if (uploader != null) { if (!config.containsKey(Constants.DB.ACCOUNT.FLAGS)) { if (BuildConfig.DEBUG) { String s = null; s.charAt(3); } } uploader.init(config); uploaders.put(uploaderName, uploader); uploadersById.put(uploader.getId(), uploader); } return uploader; }
From source file:at.bitfire.vcard4android.AndroidContact.java
protected void populateStructuredName(ContentValues row) { contact.displayName = row.getAsString(StructuredName.DISPLAY_NAME); contact.prefix = row.getAsString(StructuredName.PREFIX); contact.givenName = row.getAsString(StructuredName.GIVEN_NAME); contact.middleName = row.getAsString(StructuredName.MIDDLE_NAME); contact.familyName = row.getAsString(StructuredName.FAMILY_NAME); contact.suffix = row.getAsString(StructuredName.SUFFIX); contact.phoneticGivenName = row.getAsString(StructuredName.PHONETIC_GIVEN_NAME); contact.phoneticMiddleName = row.getAsString(StructuredName.PHONETIC_MIDDLE_NAME); contact.phoneticFamilyName = row.getAsString(StructuredName.PHONETIC_FAMILY_NAME); }