Necessary classes:
com.liferay.portlet.expando.model.ExpandoTable com.liferay.portlet.expando.model.ExpandoValue com.liferay.portal.service.ClassNameLocalServiceUtil com.liferay.portlet.expando.service.ExpandoColumnLocalServiceUtil com.liferay.portlet.expando.service.ExpandoTableLocalServiceUtil com.liferay.portlet.expando.service.ExpandoValueLocalServiceUtilHere is a example how you get a expando-value programmatically. Lets say you have a expando named "foo" for User class. You can get a user's value like this:
long userClassNameId = ClassNameLocalServiceUtil.getClassNameId(User.class.getName()); ExpandoTable userExpandoTable = ExpandoTableLocalServiceUtil.getDefaultTable(PortalUtil.getDefaultCompanyId(), userClassNameId); ExpandoColumn userExpandoTableColumn = ExpandoColumnLocalServiceUtil.getColumn(userExpandoTable.getTableId(), "foo"); ExpandoValue expandoValue = ExpandoValueLocalServiceUtil.getValue(userExpandoTable.getTableId(),userExpandoTableColumn.getColumnId(), user.getUserId()); String foo= expandoValue.getString();There is also a shorter way based on ExpandoBridge. What you have to consider when using this approach, is that permission checking is enabled when using ExpandoBridge. For example when you try to access some expando value as a non-logged in user you will get some exception because of missing permissions to access expando-values.
String education = (String)user.getExpandoBridge().getAttribute("foo");Setting value by using ExpandoValueLocalServiceUtil
ExpandoValueLocalServiceUtil.addValue(userClassNameId, userExpandoTable.getTableId(), userExpandoTableColumn.getColumnId(), user.getUserId(), "some value");Setting the same value by using ExpandoBridge
user.getExpandoBridge().setAttribute("foo", "some value");
Checking if a certain expando exists. For example an expando "hobby" for Users:
user.getExpandoBridge().hasAttribute("hobby")