Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to change string values to check if they're empty on my Android app
    text
    copied!<p>So, I'm getting a bunch of string values from a JSON object and then I'm printing them all. However, I wanted to put all the values in a String array and check to see if they're empty, and if so... change the value to "N/A" so they're not just blank. However, it recognizes which strings are blank but when I check them in the logcat, it doesn't print the name of the string that's empty. For instance, I know two strings are going to be empty, but when I check it with this:</p> <pre><code>System.out.println(nullCheck[i] + "is empty"); </code></pre> <p>"is empty" just shows up twice in the logcat. And even if I want to change the values of ANY of them, it still won't do it. It retrieves all of the strings that have data in them and prints them out just fine. I might be just overlooking something incredibly easy, but I would appreciate any help. Here's the full snippet for reference:</p> <pre><code> String supplieraddress = ""; String supplierphone = ""; String supplieremail = ""; String supplierfax = ""; String vouchercontact = ""; String supplierid = ""; String suppliername = ""; String servicetype = ""; String serviceid = ""; String vouchernotes = ""; try { voucher = reservation.getJSONArray("vouchers").getJSONObject(vouchNumber); supplieraddress = voucher.getString("supplieraddress"); supplierphone = voucher.getString("supplierphone"); supplieremail = voucher.getString("supplieremail"); supplierfax = voucher.getString("supplierfax"); vouchercontact = voucher.getString("vouchercontact"); supplierid = voucher.getString("supplierid"); suppliername = voucher.getString("suppliername"); servicetype = voucher.getString("servicetype"); serviceid = voucher.getString("serviceid"); vouchernotes = voucher.getString("vouchernotes"); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } String[] nullCheck = {supplieraddress, supplierphone, supplieremail, supplierfax, vouchercontact, supplierid, suppliername, servicetype, serviceid, vouchernotes}; for(int i = 0; i &lt; nullCheck.length; i++) { if(nullCheck[i].equals("")) { System.out.println(nullCheck[i] + "is empty"); nullCheck[i] = "N/A"; } } content.setText(Html.fromHtml( "&lt;/br&gt;&lt;b&gt;Supplier Address &lt;/b&gt;&lt;br/&gt;" + supplieraddress + "&lt;br/&gt;&lt;br/&gt;&lt;b&gt;Supplier Phone &lt;/b&gt;&lt;br/&gt;" + supplierphone + "&lt;br/&gt;&lt;br/&gt;&lt;b&gt;Supplier Email &lt;/b&gt;&lt;br/&gt;" + supplieremail + "&lt;br/&gt;&lt;br/&gt;&lt;b&gt;Supplier Fax &lt;/b&gt;&lt;br/&gt;" + supplierfax + "&lt;br/&gt;&lt;br/&gt;&lt;b&gt;Voucher Contact &lt;/b&gt;&lt;br/&gt;" + vouchercontact + "&lt;br/&gt;&lt;br/&gt;&lt;b&gt;Supplier ID &lt;/b&gt;&lt;br/&gt;" + supplierid + "&lt;br/&gt;&lt;br/&gt;&lt;b&gt;Supplier Name &lt;/b&gt;&lt;br/&gt;" + suppliername + "&lt;br/&gt;&lt;br/&gt;&lt;b&gt;Service Type &lt;/b&gt;&lt;br/&gt;" + servicetype + "&lt;br/&gt;&lt;br/&gt;&lt;b&gt;Service ID &lt;/b&gt;&lt;br/&gt;" + serviceid + "&lt;br/&gt;&lt;br/&gt;&lt;b&gt;Voucher Notes &lt;/b&gt;&lt;br/&gt;" + vouchernotes )); } </code></pre> <p>Thanks guys!</p>
 

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