I have a problem which is I can get the value in the HashMap but I cannot send this value to my class. My error is void com.paket.okulduyuru.Model.Duyuru.setPid(java.lang.String) on a null object reference
.
My setter method is:
public void setPid(String pid) {
this.pid = pid;
}
Activity:
Calendar calendar = Calendar.getInstance();
SimpleDateFormat currentDate = new SimpleDateFormat("MMM dd, yyyy");
saveCurrentDate = currentDate.format(calendar.getTime());
SimpleDateFormat currentTime = new SimpleDateFormat("HH:mm");
saveCurrentTime = currentTime.format(calendar.getTime());
duyuruRandomKey = saveCurrentDate + saveCurrentTime;
final HashMap<String, Object> duyuruMap = new HashMap<>();
duyuruMap.put("pid",duyuruRandomKey);
duyuruMap.put("date",saveCurrentDate);
duyuruMap.put("time",saveCurrentTime);
duyuruMap.put("context",duyuru_context);
duyuruMap.put("title",duyuru_baslik);
duyuruMap.put("bolum",duyuru_bolum);
duyuruMap.put("yazar",duyuru_yazar);
String pid = (String) duyuruMap.get("pid");
duyuru.setPid(pid);