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 8717145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:14:38+00:00 2026-06-13T06:14:38+00:00

My app is a trivia app that i get questions from the database. There

  • 0

My app is a trivia app that i get questions from the database. There are also topics in this app and I thought to implement this by having a column in the database specifically for holding a value that would correspond to what category that the question was. I’ve tried to import a static arraylist of arraylist of boolean values. Then i want to iterate through them to create the array based on if the value is true (my app allows for multiple categories to be able to be picked). The issue is incorporating it (the created arraylist holding topics) into my query statement. I guess the goal is something like -if column two contains these values then add them to the query- I assume this might be child’s play with a direct SQL raw query statement but tbh it looked daunting and so i’ve only ever made myself comfortable with the android alternative.

    public Cursor getQuestions() {

    List<String> topicsList = new ArrayList<String>(39);
    for(int i = 0; i < child_check_states.size(); i++) {
        for(int j = 0; j < child_check_states.get(i).size(); j++) {
            if (child_check_states.get(i).get(j) == true) {
                topicsList.add(i+""+j+"");
            }
        }
    }
    Log.d("test", topicsList.toString());

    SQLiteDatabase db = getReadableDatabase();
    Cursor cursor = db.query(DB_NAME, null, null, null, null, null, "random()");
    return cursor;
}

this is off-topic and doesn’t need to be answered, but is there perhaps a peformance issue for randomizing rows like this? I believe that i read once that is better to implement a method that uses two cursors to achieve this. my app only has 4 rows for testing so i haven’t noticed anything, but eventually i’d like to have thousands. maybe tens of thousands.

  • 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-13T06:14:39+00:00Added an answer on June 13, 2026 at 6:14 am

    Just use “IN” keyword, e.g

    SELECT * from my_table where category IN (category_1, category_3, category_4)
    

    or, in your example

    public Cursor getQuestions() {
    
    List<String> topicsList = new ArrayList<String>(39);
    for(int i = 0; i < child_check_states.size(); i++) {
        for(int j = 0; j < child_check_states.get(i).size(); j++) {
            if (child_check_states.get(i).get(j) == true) {
                topicsList.add(i+""+j+"");
            }
        }
    }
    Log.d("test", topicsList.toString());
    
    String replacementString = "(?";
    for(int i = 1 ; i < topicsList.size(); i++){
        replacementString += ", ?";
    }
    
    replacementString += ")";
    
    SQLiteDatabase db = getReadableDatabase();
    Cursor cursor = db.query(DB_NAME, <your_columns>, <category_column> IN + replacementString, topicsList.toArray(new String[topicsList.size()]), null, null, "random()");
    return cursor;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this error when I try to run my app: 2010-04-29 13:49:01.355 MyApp[56123:207]
I'm creating a Trivia app, and need some help designing my model relationships. This
app.get('/', function (req, res) { res.render('home.jade', { results: req.session.value }); }); What i would
In my C#/XAML metro app, there's a button which kicks off a long-running process.
I'm having to think hard about optimisation in an Android app for the first
I'm thinking about creating a location-aware iPhone app that could work offline by coming
I have a multithreaded app that uses sqlite. When two threads try to update
Lots of style-related jquery autocomplete questions (yow), but none that want to "match the
I am working on a web app and am having trouble with a trivial
This is my first attempt at writing a QT app, and I'm just trying

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.