Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 966159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:06:44+00:00 2026-05-16T02:06:44+00:00

I’m writing a custom ContentProvider that serves up content consisting of a single, constant

  • 0

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.

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:

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);
    }
}

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:

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)...

Could anyone shed some light on what this method should be doing to return a correct-looking row to the client?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T02:06:44+00:00Added an answer on May 16, 2026 at 2:06 am

    For what you’re doing you should check out the MatrixCursor. It uses the AbstractCursor#fillWindow implementation which calls toString on every object. Since you’re just sending a string anyway it should work fine for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.