lundi 25 juillet 2016

Proper way of testing a string for null empty or "null" ...? [duplicate]

This question already has an answer here:

Any one know how to fix the null pointer excepction.....? in ths code.

Log Information = I/Value in String: null

 public ArrayList GetEmailContacts(ArrayList data) {
        ArrayList ContactsWithEmailId = new ArrayList();
        for (int i = 0; i < data.size(); i++) {
            String name = String.valueOf(data.get(i));
            String tempdata = mySqlitedb.getEmailConntacts(name);
            Log.i("Value in String",tempdata);
            if ((!tempdata.equals("null")) && (!tempdata.equals("")) && (tempdata!=null)) 
            {
                ContactsWithEmailId.add(tempdata);
            }

        }
        return ContactsWithEmailId;
    }

Aucun commentaire:

Enregistrer un commentaire