public void saveProgress(String email, String sectionRead,
String lastSection) {
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
String query = "select from " + Profile.class.getName() + " where email=='" + email + "'";
Profile result = ((Collection<Profile>) pm.newQuery(query)
.execute()).iterator().next();
result.setSectionRead(sectionRead);
result.setCurrentHistory(lastSection);
} catch (NoSuchElementException e) {
Profile result=new Profile(email);
result.setSectionRead(sectionRead);
result.setCurrentHistory(lastSection);
pm.makePersistent(result);
} finally {
pm.close();
}
}