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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:50:24+00:00 2026-05-31T05:50:24+00:00

My app has 3,000 exam questions in .sqlite file. And these questions are dynamically

  • 0

My app has 3,000 exam questions in .sqlite file. And these questions are dynamically selected and sorted by user’s demand (for example, ‘sort by count of wrong answer’, ‘select non-accessed questions only’).

Whenever user makes a selection, app makes corresponding SQL statement and by using sqlite3, all the result sets are sent into NSMutableArray(Question class). But as you will note, this is time-consuming process (about 2~3 secs and UI stops responding while doing so).

So I want to make a ‘cursor’ class which has rowCount() and moveToRow(int index) methods.

With this, my idea is

Cursor c = [[Cursor alloc] init] query(
    "SELECT id,qtext,answer,a1,a2,... FROM TABLE WHERE id > 100"
)]; 
    // at this time, just a cursor is given, no need to iterate all the retrieved rows

for (i=0; i > c.rowCount(); i++) {
    c.moveToRow(i);
    ShowQuestionDetail(c);
}

Like this.

I know that CoreData fits this purpose, but I need to share .sqlite file with android version of this app. CoreData requires all the table names and field names start with Z_ prefix, but I can’t modify schemes of the .sqlite file. Also I need to use sqlcipher, and CoreData doesnt work with sqlcipher.

FMDB doesn’t support methods that gives count of retrieved rows and move to specific row.

Is there any other SQLite wrapper libraries which supports this functionality?

Someone suggests making an ‘catalog’ array which only contains id of the retrieved rows, and fetch row each time when moveToRow() called. I agree that’s an good alternative, but I want to find another way.

  • 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-31T05:50:25+00:00Added an answer on May 31, 2026 at 5:50 am

    Another approach maybe to limit your query to 1 row of data. That is make the call at cellForRowAtIndex. From my experience – it’s better to have a separate method for this –
    you could even go one step further and add a DataCache layer for caching to memory as per coredata if you really needed to.

    Something like this ….
    http://code.google.com/p/airband/source/browse/trunk/airband/Classes/DataCache.h?spec=svn103&r=103

    Eg.
    – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    //init your cell

     NSDictionary *dict = [self questionDataForCellAtIndexPath:indexPath];
     // set the cell values
    }
    
    
    
    -(NSDictionary*)questionDataForCellAtIndexPath:(NSIndexPath *)indexPath{
    
            //ENTER_METHOD;
        NSDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:0];
    
        NSString  *qry = [NSString stringWithFormat: @"SELECT id,qtext,answer,a1,a2,... FROM TABLE WHERE id ORDER BY id DESC limit 1 offset %d", [indexPath row]];
    
    // you could look up here for previously accessed rows from DataCache
        //  NSDictionary *cachedRow = [DATAENV.cache objectForKey:num];
    ///if (cachedRow == nil) {
        //  go get it
       //   else return it 
    
        DLog(@"qry%@",qry );
         EGODatabaseResult *result  = [appDelegate.userdb executeQuery:qry];
    
        if ([result count]==0) {
            return dict;
        }
        for(EGODatabaseRow *row in result) {
            [dict setValue:[row stringForColumn:@"name"]  forKey:@"name"];
    
        }
        return dict;
    }
    

    check out my fork for EgoDatabase.
    https://github.com/jdp-global/egodatabase

    it also includes asynchronous methods that are non blocking.

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

Sidebar

Related Questions

My app has many controls on its surface, and more are added dynamically at
My app has several buttons which trigger different events. The user should NOT be
My app has a session timeout after 30 minutes. If the user has a
My app uses XML to save user data to a file. I have just
My app has a DataGridView object and a List of type MousePos. MousePos is
My app has three text fields: 1) Username // Initialization code usernameTextField = [[UITextField
My app has 6 menu items, so the OS shows the first 4, then
My app has some table cells that vary in height. The cells can also
My app has to load an image from a http server and displaying it
My app has normal users: those which come through a typical signup page facebook(FB)

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.