Problem with contact query and null string
<p>EDIT: SOLVED IT :( AFTER SPENDING HOURS ON IT, IT WAS THE SIMPLEST OF SOLUTIONS. CORRECT CODE BELOW.</p>

<p>Ok. So I have the query working where I can look someone up by their phone number. What I want to do is if the phone number I look up doesn't exist, it just returns the phone number. Here's what I have so far:</p>

<pre><code>Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber)); 

Cursor c = context.getContentResolver().query(lookupUri, new String[]{PhoneLookup.DISPLAY_NAME}, null, null, null);  

while(c.moveToNext()) {
    conname = c.getString(c.getColumnIndexOrThrow(PhoneLookup.DISPLAY_NAME));
    }
    if (conname==null || conname.equals("") || conname.equals("null")) {
        conname = phoneNumber;
    }

if (messages.length &gt; -1) {
    smsToast = conname + ":\n'" + messages[0].getMessageBody() + "'";
    Toast.makeText(context, smsToast, Toast.LENGTH_LONG).show();
    Log.e("Text Thing", conname + " ugh");
    Log.e("Text Thing", phoneNumber);
}
</code></pre>

<p>I tried everything to turn conname (the contacts name) back to the phoneNumber. It says conname = null if it doesn't return anything on the toast. So what am I missing?</p>
