sqlite query to retrieve all rows where not null android
<p>Good day, I have like 2 question here:</p>

<p>First a background information.</p>

<p>from the android documentation, when querying a database, we have to return a column with name "_id" for it to work with a cursor adapter. Now in my implementation, lets say i have 3 columns "_id", "column A" "column B". </p>

<p>so if i have 8 entry rows in my database table, where the 1st 3 rows in column A is filled and the next 5 rows in column B is filled. if i query the database for column B and use the code below in my bindview, the cursor returns all the rows which will result in the first 3 entries being null and the last 5 items being shown in my gridview of images.</p>

<p>here is my bindView:</p>

<pre><code>@Override
public void bindView(View view, Context context, Cursor cursor) {
     ViewHolder holder = (ViewHolder)view.getTag();
 int columnIndex = cursor.getColumnIndexOrThrow(columnName);
 final String name = cursor.getString(columnIndex);
     while(cursor.moveToNext()){

            if(name != null){
             Log.d(TAG, "string name in gridimageadapter is " + name);

             BitmapFactory.Options options = new BitmapFactory.Options();
             Bitmap bitmap = BitmapFactory.decodeFile(name);

             Bitmap newbitmap = Bitmap.createScaledBitmap(bitmap, 200, 200, false);
             if(holder.image != null){
                 holder.image.setImageBitmap(newbitmap); 
             }
             bitmap.recycle();

            }
     }
}
</code></pre>

<p>so my questions are:</p>

<ol>
<li><p>How do i write an sqlite query to return a column with rows not null? my current implementation is:</p>

<p>public Cursor retrieveTag(String tag){</p>

<pre><code>    String[] condition = {KEY_ID,tag};
Cursor cursor = db.query(DATABASE_TABLE, condition, null, null, null, null, null);      
    return cursor;
}
</code></pre></li>
<li><p>from the BindView code, if i use this condition like </p>

<p>if( !name.equals(null) || !name.equals("")){
  } </p></li>
</ol>

<p>i get a NullPointerException on the it. Why is that?.. this is the correct way to test for Strings right?..</p>

<p>Hope am clear in my question and any help will be greatly appreciated. Thank you.</p>
