Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Let's say you upload a file to your server, that contains a single line:</p> <pre><code>1.2.3.4 </code></pre> <p>The process is similar for Android and BB:</p> <p>1- Retrieve the file from the server. You'll probably have a byte array as result.</p> <p>2- Convert it to a String with the proper encoding. In case the txt only contains numbers and dots, the encoding is not really important since these are ASCII chars, and ASCII chars are compatible with most usual default encodings like UTF-8 and ISO-8859. So we could probably instantiate the string without dealing with the encoding, like this: <code>String fileContent = new String(byte[] downloadedData)</code>. Otherwise, make sure you know in advance the txt file encoding and instantiate the string with that encoding.</p> <p>3- Split the string using the dots as separators. In Android you can do it like this: <code>String[] splitted = String.split(fileContent, '.')</code>, or use a <code>StringTokenizer</code>. In BB, as it is based in CLDC, this method in String is not available so you should code it yourself, or use/port one from a well tested library (like Apache Commons' org.apache.commons.lang3.StringUtils.split). After this step you'll have an array of strings, each string being a number ({"1","2","3","4"} in the example).</p> <p>4- Now create a int array of the same length, and convert each string in the array to its equivalent int, using <code>Integer.parseInt(splitted[i])</code> on each element <code>i</code>.</p> <p>5- Get the version for your app and perform the same steps to get an array of int. In BB, you can call <code>ApplicationDescriptor.currentApplicationDescriptor().getVersion()</code>. In Android, <code>PackageInfo.versionCode</code> or <code>PackageInfo.versionName</code>, depending on what you have specified in the manifest.</p> <p>6- Notice both arrays don't need to be of the same length. You could have written "1.2.3.4" in your txt, but have "1.2.3" in your AndroidManifest.xml or BlackBerry_App_Descriptor.xml. Normalize both resulting int arrays to have the same length (the lenght of the longer one), and fill the added elements with zeroes. Now you'll have two int arrays (in the example, txtVersion = {1,2,3,4} and appVersion = {1,2,3,0}). Iterate comparing versions one by one. The rule is: if txtVersion[i] > appVersion[i], then you are out of date and an upgrade is needed.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload