title: Android ContentProvider with custom query does not show data
body: <p>Today I am very confused, because my custom content provider does not work as expected. Namely, it does'nt show any data in the list on my Samsung S5 (Android 4.4.2). But, more confusing, in the Android Simulator (Genymotion, same Android version) it works. Why?</p>
  
  <pre><code>private static final String AUTHORITY = "[PACKAGE_NAME].helper.db.provider.PublicationContentProvider";
  public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/" + PublicationColumns.TABLE_NAME);
  
  public static final int PUBLICATIONS = 1;
  public static final int PUBLICATION_ID = 2;
  
  private static final UriMatcher sURIMatcher = new UriMatcher(UriMatcher.NO_MATCH);
  
  static {
      sURIMatcher.addURI(AUTHORITY, PublicationColumns.TABLE_NAME, PUBLICATIONS);
      sURIMatcher.addURI(AUTHORITY, PublicationColumns.TABLE_NAME + "/#", PUBLICATION_ID);
  }
  
  private static final Map&lt;String, String&gt; sProjectionMap = new HashMap&lt;String, String&gt;();
  
  static {
      sProjectionMap.put(PublicationColumns._ID, PublicationColumns.KEY_FULL_ID);
      sProjectionMap.put(PublicationColumns.KEY_PUBLICATION_CODE, PublicationColumns.KEY_FULL_PUBLICATION_CODE);
      sProjectionMap.put(PublicationColumns.KEY_PUBLICATION_NAME, PublicationColumns.KEY_FULL_PUBLICATION_NAME);
      sProjectionMap.put(PublicationColumns.KEY_PUBLICATION_THUMBNAIL, PublicationColumns.KEY_FULL_PUBLICATION_THUMBNAIL);
  }
  
  @Override
  public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
      SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
  
      String query = "SELECT " + PublicationColumns.KEY_FULL_ID + ", " + PublicationColumns.KEY_FULL_PUBLICATION_NAME + ", "
              + PublicationColumns.KEY_FULL_PUBLICATION_CODE + ", " + PublicationColumns.KEY_FULL_PUBLICATION_THUMBNAIL
              + " FROM " + PublicationColumns.TABLE_NAME + " WHERE " + PublicationColumns.KEY_FULL_ID + " IN (SELECT "
              + AbocodePublicationColumns.KEY_FULL_PUBLICATION_ID + " FROM " + AbocodePublicationColumns.TABLE_NAME
              + " WHERE " + AbocodePublicationColumns.KEY_FULL_ABO_ID + " IN (SELECT " + LoginColumns.KEY_FULL_ID
              + " FROM " + LoginColumns.TABLE_NAME + " WHERE " + LoginColumns.KEY_FULL_LOGIN_VALID + "='1'));";
  
      int uriType = sURIMatcher.match(uri);
  
      boolean useCustomQuery = false;
  
      switch (uriType) {
          case PUBLICATION_ID:
              queryBuilder.appendWhere(PublicationColumns._ID + "=" + uri.getLastPathSegment());
              break;
          case PUBLICATIONS:
              if (projection == null &amp;&amp; TextUtils.isEmpty(selection)) {
                  useCustomQuery = true;
              }
              break;
          default:
              throw new IllegalArgumentException("Unknown URI");
      }
  
      Cursor cursor;
      if (useCustomQuery) {
          cursor = dbAdapter.getReadableDatabase().rawQuery(query, null);
      } else {
          queryBuilder.setTables(PublicationColumns.TABLE_NAME);
          queryBuilder.setProjectionMap(sProjectionMap);
          cursor = queryBuilder.query(dbAdapter.getReadableDatabase(), projection, selection, selectionArgs, null, null, sortOrder);
      }
      cursor.setNotificationUri(getContext().getContentResolver(), uri);
      return cursor;
  }
  ....
  </code></pre>
  
  <p>I also tried it with the QueryBuilder and default query, but with the same results. It seems that I changed something, but I don't know what. But again, in the Simulator it all works fine! Any help would be appreciated.</p>
  
  <p>EDIT //
  On an older device with Android 4.2.2 it works, too. The only device, where it does not work is my Samsung Galaxy S5.</p>
  
  <p>Thank you!</p>