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

  • SEARCH
  • Home
  • 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 7981775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:28:48+00:00 2026-06-04T10:28:48+00:00

I’m working on application, in which first activity gets random value from database and

  • 0

I’m working on application, in which first activity gets random value from database and sends it to the next activity as a string.

I know exactly how this can be done in sql:

SELECT column FROM table
ORDER BY RANDOM()
LIMIT 1

After some attempts to use it in app I’ve come to this:

Cursor send = database.query(TABLE_NAME, new String[] { COLUMN_NAME }, null, null, null, null, "RANDOM() LIMIT 1");

Bundle b = new Bundle();
b.putString("description", send.getString(send.getColumnIndex(COLUMN_NAME)));

But I got error on the last line after pressing button to open the second activity.


Added Log:

05-22 22:14:24.202: E/AndroidRuntime(14259): FATAL EXCEPTION: main
05-22 22:14:24.202: E/AndroidRuntime(14259): android.database.CursorIndexOutOfBoundsException: Index 1 requested, with a size of 1
05-22 22:14:24.202: E/AndroidRuntime(14259):    at android.database.AbstractCursor.checkPosition(AbstractCursor.java:400)
05-22 22:14:24.202: E/AndroidRuntime(14259):    at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136)
05-22 22:14:24.202: E/AndroidRuntime(14259):    at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50)
05-22 22:14:24.202: E/AndroidRuntime(14259): at com.example.ListAction$1.onItemClick(ListAction.java:90)
05-22 22:14:24.202: E/AndroidRuntime(14259):    at android.widget.AdapterView.performItemClick(AdapterView.java:292)
05-22 22:14:24.202: E/AndroidRuntime(14259):    at android.widget.AbsListView.performItemClick(AbsListView.java:1177)
05-22 22:14:24.202: E/AndroidRuntime(14259):    at android.widget.AbsListView$PerformClick.run(AbsListView.java:2705)
05-22 22:14:24.202: E/AndroidRuntime(14259):    at android.widget.AbsListView$1.run(AbsListView.java:3458)
05-22 22:14:24.202: E/AndroidRuntime(14259):    at android.os.Handler.handleCallback(Handler.java:605)
05-22 22:14:24.202: E/AndroidRuntime(14259):    at android.os.Handler.dispatchMessage(Handler.java:92)
05-22 22:14:24.202: E/AndroidRuntime(14259):    at android.os.Looper.loop(Looper.java:137)
05-22 22:14:24.202: E/AndroidRuntime(14259):    at android.app.ActivityThread.main(ActivityThread.java:4507)
05-22 22:14:24.202: E/AndroidRuntime(14259):    at java.lang.reflect.Method.invokeNative(Native Method)
05-22 22:14:24.202: E/AndroidRuntime(14259):    at java.lang.reflect.Method.invoke(Method.java:511)
05-22 22:14:24.202: E/AndroidRuntime(14259):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
05-22 22:14:24.202: E/AndroidRuntime(14259):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
05-22 22:14:24.202: E/AndroidRuntime(14259):    at dalvik.system.NativeStart.main(Native Method)
  • 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-06-04T10:28:50+00:00Added an answer on June 4, 2026 at 10:28 am

    I think the problem is that you should point your cursor to the first row. I have not found this in your code:

    if (!send.moveToFirst()) {
        Log.d(TAG, "Cannot move to first row of the Cursor!");
        return;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
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
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small

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.