Below is the snippet for setting value to the Element - I have one Single Text element and Multi Line Text element as part of my model. Get that element using its "fieldName" (that you provided while creating CFM) and then set the content.
Note :
Any updates/persists to content fragment calls for a commit unless specified otherwise.
if (contentFragment != null) {
ContentElement textField = contentFragment.getElement("textField");
LOG.debug("Textfield content type={} and content={}", textField.getContentType(),textField.getContent());
textField.setContent("Text/Single line text content inside the created CF", "text/plain");
ContentElement description = contentFragment.getElement("description");
LOG.debug("description content type={} and content={}", description.getContentType(),description.getContent());
description.setContent("Description/Multi line text content inside the created CF", "text/plain");
resourceResolver.commit();
}For any other operations on the content fragment, you can refer the API doc - https://www.adobe.io/experience-manager/reference-materials/6-5/javadoc/com/adobe/cq/dam/cfm/ContentFragment.html