title: Android Content provider Cursor returns 0
body: <p>I have looked at this for a couple of days now and I completely can't work out why my content provider return 0 using the arguments I am passing it.</p>
  
  <p>Here's my contentResolver code:</p>
  
  <pre><code>String[] expenditureProjection = {
              BusinessOpsDatabase.COL_EXPEND_CAT_ID,
              BusinessOpsDatabase.COL_EXPEND_DATE,
              BusinessOpsDatabase.COL_EXPEND_AMOUNT,
              BusinessOpsDatabase.COL_EXPEND_DESC,
              BusinessOpsDatabase.COL_STERLING_EXCHANGE,
              BusinessOpsDatabase.COL_COMPANY_ID,
              BusinessOpsDatabase.CURRENCY_ID,
              BusinessOpsDatabase.COL_MOD_DATE
      };
      // Defines a string to contain the selection clause
      String selectionClause = null;
  
      // An array to contain selection arguments
      String[] selectionArgs = {expend_id.trim()};
  
      selectionClause = BusinessOpsExpenditureProvider.EXPENDITURE_ID + "=?";
  
      Log.d(TAG, expend_id+" Selected from list.");
  
      Cursor expendCursor = getContentResolver().query(
              BusinessOpsExpenditureProvider.CONTENT_URI, expenditureProjection, selectionClause, selectionArgs, null);
      if (null == expendCursor) {
          Log.d(TAG, "Expenditure cursor: Is null");
      } else if (expendCursor.getCount() &lt; 1) {
          Log.d(TAG,"Expenditure cursor: Search was unsuccessful: "+expendCursor.getCount());
      } else {
          Log.d(TAG,"Expenditure cursor: Contains results");
  
          int i=0;
          expendCursor.moveToFirst();
          // loop through cursor and populate country array
          while (expendCursor.isAfterLast() == false)
          {
              expend_date_edit.setText(expendCursor.getString(1));
              expend_amount_edit.setText(expendCursor.getString(3));
              expend_desc_edit.setText(expendCursor.getString(4));
  
              i++;
              expendCursor.moveToNext();
          }
      }
  </code></pre>
  
  <p>Here's my content provider query method:</p>
  
  <pre><code>@Override
  public Cursor query(Uri uri, String[] projection, String selection,
                      String[] selectionArgs, String sortOrder) {
      SQLiteDatabase db = mDB.getWritableDatabase();
  
      // A convenience class to help build the query
      SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
  
      qb.setTables(BusinessOpsDatabase.TABLE_EXPENDITURE);
  
      switch (sURIMatcher.match(uri)) {
          case EXPENDITURE:
              if(selection != null &amp;&amp; selectionArgs != null){
                  //values.get("company_contact");
              String segment = uri.getLastPathSegment();
              Log.d(TAG, "Last path segment: "+ segment);
              String whereClause = BusinessOpsDatabase.EXPENDITURE_ID + "="+ selectionArgs[0];
              Log.d(TAG, "Where clause: "+whereClause);
              }
              break;
          case EXPENDITURE_ID:
              // If this is a request for an individual status, limit the result set to that ID
              qb.appendWhere(BusinessOpsDatabase.EXPENDITURE_ID + "=" + uri.getLastPathSegment());
              break;
          default:
              throw new IllegalArgumentException("Unsupported URI: " + uri);
      }
  
  
      // Query the underlying database
      Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, null);
  
      // Notify the context's ContentResolver if the cursor result set changes
      c.setNotificationUri(getContext().getContentResolver(), uri);
  
      // Return the cursor to the result set
      return c;
  }
  </code></pre>
  
  <p>I'm printing the whereclause to the log and I see '_id=3' which should be fine because I have pulled off a copy of my SQLite database and I can see that the expenditure table has an _id 3 row in it. Any Ideas? </p>