title: Has MatrixCursor implementation within Android P changed?
body: <p>Recently I have observed a large number of crashes for an app that I maintain when the Android P developer preview is used.</p>
  
  <p>Diving (deep) into the project's code, I have found the problem method to be the following: </p>
  
  <pre class="lang-java prettyprint-override"><code>public static &lt;T&gt; T get(MatrixCursor cursor, int column) {
      try {
          cursor.moveToFirst();
          Method get = MatrixCursor.class.getDeclaredMethod("get", int.class);
          get.setAccessible(true);
          return (T) get.invoke(cursor, column);
      } catch (Exception e) {
          throw new IllegalArgumentException("Android has changed the implementation of MatrixCursor?!");
      }
  }
  </code></pre>
  
  <p>From what I understand, this code is used to retrieve a custom object from the MatrixCursor directly, rather than a primitive type, byte array or String. There has previously been a <a href="https://github.com/aosp-mirror/platform_frameworks_base/blob/master/core/java/android/database/MatrixCursor.java#L64-L76" rel="nofollow noreferrer">private method</a> within <code>MatrixCursor</code> that performs this internally, and it is this method that we access through reflection.</p>
  
  <p>Needless to say, there's a number of issues with this approach. As far as I am aware, reflection to access private APIs is a feature that Android advises <strong>heavily</strong> against. Nevertheless, until the Android P preview, this seems to have been working as expected.</p>
  
  <p>This leads me to raise the following questions:</p>
  
  <p>Has <code>MatrixCursor</code>'s implementation changed or is reflection totally deprecated as of Android P? </p>
  
  <p>Sadly, I am not 100% clued up on what alternatives I have to avoid this issue. Any suggestions for that are greatly appreciated, is there a Cursor that can be used to store custom objects? </p>