I am designing a j2me application prototype that requires reading the users phone calendar in order to retrieve the users schedule information. I use JSR 75 PIM API. I actually can read the date values but while sending the value to the database, it only saves the first date. I can't seem to figure out the real problem behind. Help please....
I use J2me for the client side, PHP for the server and MYSQL for the database.
I try to adopt the code of PIM example from the sun wireless toolkit and in its ItemSelectionScreen class. I try to modify the code like this
String getDisplayedField(PIMItem item) throws PIMException {
int fieldCode = Event.REVISION;
if (item.countValues(fieldCode)!= 0) {
long b = item.getDate(fieldCode, 0);
cal = Calendar.getInstance();
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
cal.set(Calendar.HOUR,12);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.AM_PM, Calendar.AM);
Date d = new Date(b);
cal.setTime(d);
Date t= new Date(cal.getTime().getTime());
a=t.toString().substring(0,10);
c=t.toString().substring(23,28);
f=t.toString().substring(10,19);
//fieldValue1=a.concat(c);
fieldValue=a.concat(c).concat(f);
System.out.println(fieldValue);
//fieldValue=d.toString();
//fieldValue=d.toString().substring(0, 9);
}
return fieldValue;
}
My thought was since the "fieldValue" is a string, after getting the value I can split in in the server side and get only the required info but that's not the case here. So, my question is how can I send each date values separately to the server and store it in the database?
I'm not sure what your code snippet is supposed to do. I don't see anywhere it actually fetches anything from the calendar.
If you want to fetch all events from the calendar, you do this:
Now you have opened your calendar, and is ready to fetch all the events into the
events
variable, and loop through them.Just to be clear: The
myHTTPConnection
is pseudo code. You need to add your own code that sends the data to your site there.