Following the guidelines and checking examples I managed to write that. It worked superbly on a simulator. The moment I copied that to a actual device, boom, the upload isn't working anymore. I was stuck. After some effort I found that you needed to append a connection string after every URL for the blackberry internet access to work properly.
The connection string can be obtained as follows
public static String getConnectionString() {
String connectionString = null;
if (DeviceInfo.isSimulator()) {
if (USE_MDS_IN_SIMULATOR) { //Define the Boolean constant
connectionString = ";deviceside=false";
} else {
connectionString = ";deviceside=true";
}
} else if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) {
connectionString = ";interface=wifi";
} else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT) {
String carrierUid = getCarrierBIBSUid();
if (carrierUid == null) {
connectionString = ";deviceside=true";
} else {
connectionString = ";deviceside=false;connectionUID="
+ carrierUid + ";ConnectionType=mds-public";
}
} else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS) {
connectionString = ";deviceside=false";
} else if (CoverageInfo.getCoverageStatus() == CoverageInfo.COVERAGE_NONE) {
} else {
connectionString = ";deviceside=true";
}
return connectionString;
}