But unless the data you receive needs to be really dynamic, I don't think the overhead is worth it.
I agree that doing XML parsing on a real phone could cause some major memory headaches. All the database stuff I've done to phones has been through a web app, but I tend to pass stuff back to the app in some sort of delimited format. You will not get Access to run on the phone. Even if you did get some db to run, memory is so limited that some sort of delimited format would be a better option, although still not recommended.
In many cases, I use a sort of chunked encoding with two bytes as the delimiter. 'me' = mission element, then some well defined data after it, then 'mp' for the map, then 'en' for end of data.
On the j2me client I lock down a two byte array so I'm doing as little dynamic memory usage as possible.
This is a code snipet that came from an app that had to connect to an existing php app. I was able to add to the php to respond differently to the j2me app.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| private static final String ifModifiedKey = "IF-Modified-Since"; private static final String ifModifiedData = "20 Jan 2001 16:19:14 GMT"; private static final String userAgentKey = "User-Agent"; private static final String userAgentData = "Profile/MIDP-1.0 Configuration/CLDC-1.0"; private static final String contentLangKey = "Content-Language"; private static final String contentLangData = "en-US"; private static final String contentTypeKey = "Content-Type"; private static final String contentTypeUrlData = "application/x-www-form-urlencoded"; private static final String contentTypeFormData = "multipart/form-data; boundary=---1234"; private static final byte[] boundaryBytes = "-----1234".getBytes();
String url = "http://www.yourhost.com/yourapp/login.php"; try { c = (HttpConnection)Connector.open(url); c.setRequestMethod(HttpConnection.POST); c.setRequestProperty(ifModifiedKey, ifModifiedData); c.setRequestProperty(userAgentKey,userAgentData); c.setRequestProperty(contentLangKey, contentLangData); c.setRequestProperty(contentTypeKey,contentTypeUrlData);
os = c.openOutputStream(); os.write("namefield=".getBytes()); usernameBytes = tfLoginName.getString().getBytes(); os.write(usernameBytes); os.write("&passfield=".getBytes()); os.write(tfLoginPass.getString().getBytes()); os.write("&login=Log+In\n".getBytes()); |
Reading the response method looked like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| boolean done=false; while (!done) { opcode[0] = (byte) is.read(); if (opcode[0]==-1) { return amtread; } amtread++;
opcode[1] = (byte) is.read(); if (opcode[1]==-1) { return -1; } amtread++; if ((opcode[0]=='m') && (opcode[1]=='e')) { } |
This is not meant to be pretty, it was meant to save as much dynamic memory allocation as possible. I just don't trust the j2me garbage collectors.
Also, the back end for this is mysql, I wouldn't use Access for a web app unless I knew it was for a limited audience or there was some serious customer requirement and I couldn't talk them out of it.
Hopefully that helps a little.
Wood