Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat to do in custom ContentProvider's fillWindow() method?
    primarykey
    data
    text
    <p>I'm writing a custom ContentProvider that serves up content consisting of a single, constant string which I represent as a one-row table having columns _id = 0 and value = "SomeString". This string is not stored in a database, so I developed a subclass of CrossProcessCursor that has does everything required to behave like what I described above.</p> <p>The documentation for CrossProcessCursor is very sparse and doesn't really explain what the fillWindow() method should be doing beyond the obvious. Based on the descriptions of CursorWindow's methods, I put the following together, which I thought should cover it:</p> <pre><code>public class MyCursor implements CrossProcessCursor { ... public void fillWindow(int pos, CursorWindow window) { if (pos != 0) { // There's only one row. return; } window.clear(); window.allocRow(); // TODO: Error check, false = no memory window.setNumColumns(2); window.setStartPosition(0); window.putLong(0, 0, 0); window.putString("SomeString", 0, 1); } } </code></pre> <p>As expected, it gets called with pos = 0 when a client application requests the content, but the client application throws an exception when it tries to go after the first (and only) row:</p> <pre><code>Caused by: java.lang.IllegalStateException: UNKNOWN type 48 at android.database.CursorWindow.getLong_native(Native Method) at android.database.CursorWindow.getLong(CursorWindow.java:380) at android.database.AbstractWindowedCursor.getLong(AbstractWindowedCursor.java:108) at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:194) at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:248) at android.database.CursorWrapper.moveToFirst(CursorWrapper.java:86) ...(Snipped)... </code></pre> <p>Could anyone shed some light on what this method should be doing to return a correct-looking row to the client?</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload