title: Trouble with CursorAdapter and CursorLoader android
body: <p>Good day, please could somebody help me find out what's wrong with my code. I am probably missing something. Nothing is displayed from my <code>CursorAdapter</code>.
  Have been struggling with here for some time now.
  Any help will be highly appreciated!!</p>
  
  <pre><code>public class ManageTagFragment extends Fragment implements LoaderCallbacks&lt;Cursor&gt; {
  
      private static String TAG = "Image_Debugger";
      private static final int IMAGE_LOADER = 0;
      TextView text;
      GridView grid;
      CustomGridImageAdapter imageAdapter;
      Cursor cursor;
      ImageDB dbadapter;
      private Cursor c;
  
      @Override
      public void onCreate(Bundle savedInstanceState){
          super.onCreate(savedInstanceState);
          dbadapter = new ImageDB(getActivity().getApplicationContext());
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
          View view = inflater.inflate(R.layout.wallpaper_images, container, false);      
          grid = (GridView)view.findViewById(R.id.gridview);
          return view;
      }
  
      @Override
      public void onActivityCreated(Bundle savedInstanceState){
          super.onActivityCreated(savedInstanceState);    
          imageAdapter = new CustomGridImageAdapter(getActivity(), null, 0);
          grid.setAdapter(imageAdapter);
          imageAdapter.notifyDataSetChanged();
          getActivity().getSupportLoaderManager().initLoader(IMAGE_LOADER, null, this);
      }
  
      @Override
      public Loader&lt;Cursor&gt; onCreateLoader(int id, Bundle args) {
          return new CustomCursorLoader(getActivity().getApplicationContext(), dbadapter, ImageDB.IMAGES);
      }
  
      @Override
      public void onLoadFinished(Loader&lt;Cursor&gt; loader, Cursor data) {
          imageAdapter.swapCursor(data);
      }
  
      @Override
      public void onLoaderReset(Loader&lt;Cursor&gt; args) {
          imageAdapter.swapCursor(null);  
      }
  
      public static final class CustomCursorLoader extends SimpleCursorLoader {
  
          String columnname;
          ImageDB dbadapter;
          ArrayList&lt;String&gt; imageuri = new ArrayList&lt;String&gt;();
  
          public CustomCursorLoader(Context context, ImageDB dbadapter, String columnname){
              super(context);
              this.dbadapter = dbadapter;
              this.columnname = columnname;
          }
  
          public CustomCursorLoader(Context context,String columnname){
              super(context);
              this.columnname = columnname;
  
          }
  
          @Override
          public Cursor loadInBackground() {
              Cursor cursor = null;
              dbadapter.open();
  
              Log.d(TAG, "retrieving Images from database now");
              cursor = dbadapter.retrieveTag(columnname);
  
              if(cursor.moveToFirst()){
                   final int index = cursor.getColumnIndex(columnname);
  
                  do {
                      final String val = cursor.getString(index); // this is just
                                                                  // for test
                      if (val != null) {
                          Log.d(TAG, "files are" + val);
                          imageuri.add(val);
                      }
  
                  } while (cursor.moveToNext());
              }   
              return cursor;
          }
      }
  }
  </code></pre>
  
  <p>CustomGridImageAdapter.java:</p>
  
  <pre><code>public class CustomGridImageAdapter extends CursorAdapter {
      private static String TAG = "Image_Debugger";
      private LayoutInflater inflater;
      private int count;
  
      public CustomGridImageAdapter(Context context, Cursor cursor, int flags) {
          super(context, cursor, flags);
          inflater = LayoutInflater.from(context);
          Log.d(TAG, "calling grid imageadapter now");
      }
  
      @Override
      public int getCount() {
          return count;
      }
  
      @Override
      public Object getItem(int position) {
          return position;
      }
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
      @Override
      public void bindView(View view, Context context, Cursor cursor) {
          Log.d(TAG, "calling bind view");
          ViewHolder holder = (ViewHolder) view.getTag();
          String name = cursor.getString(cursor
                  .getColumnIndexOrThrow(ImageDB.IMAGES));
          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, 120, 120, false);
          holder.image.setImageBitmap(newbitmap);
  
      }
  
      @Override
      public View newView(Context context, Cursor cursor, ViewGroup container) {
          Log.d(TAG, "calling new view here");
          ViewHolder holder = new ViewHolder();
          View view = inflater.inflate(R.layout.media_view, container, false);
  
          holder.image = (ImageView) view.findViewById(R.id.media_image_id);
          holder.image.setLayoutParams(new GridView.LayoutParams(100, 100));
          holder.image.setScaleType(ImageView.ScaleType.FIT_CENTER);
          view.setTag(holder);
  
          return view;
      }
  
      class ViewHolder {
          ImageView image;
          TextView item_name;
      }
  }
  </code></pre>