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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:58:27+00:00 2026-05-27T13:58:27+00:00

I am doing a Bible application ,i have a default Bible database english DB.Sqlite,the

  • 0

I am doing a Bible application ,i have a default Bible database english DB.Sqlite,the use can download different language database within the application through INAPP,I know how to do the downloading,but my problem is when the user download the hebrew language database ,there are 10 language option buttons in the app.if the user download the hebrew database ,the hebrew button will enabled and he can tap the button and view it in a tableview,but when he tap the hebrew button the application database need to be switched according to the user wants,that is if the user tap the hindi database button if the user downloaded the hindi database it need to be viewed in the tableview,the the user tap the hebrew button it need to switch that database with the hebrew ,and load hebrew database in the tableview.I have the done the loading of english database how to reload this with the downloaded databases?
my code for showing english database is
in.h

#import <sqlite3.h>

#define DbName @"BibleDB.sqlite"

@interface DbHandler : NSObject {

}

+(void)createEditableCopyOfDatabaseIfNeeded;
+(NSString *) dataFilePath:(NSString *)path;

// Malayalam Version
+(int)mNumberOfChaptersInBook:(NSString *)book;
+(int)mNumberOfVerseForChapter:(NSString *)chapter andBook:(NSString *)book;
+(NSMutableArray *)mVerseForChapter:(NSString *)chapterNo OfBook:(NSString *)book;
+(NSString *)mVerseForVerseNo:(NSString *)verseNo OfChapter:(NSString *)chapterNo OfBook:(NSString *)book;
//+(NSString *)mVerseForVerseNo:(NSString *)verseNo OfChapter:(NSString *)chapterNo OfBook:(NSString *)book FromDB:(sqlite3 *)database;


// English Version
//+(int)eNumberOfChaptersInBook:(NSString *)book;
+(NSMutableArray *)eVerseForChapter:(NSString *)chapterNo OfBook:(NSString *)book;
+(NSMutableArray *)verseForSearchTag:(NSString *)searchTag;

//Hindi version
+(NSMutableArray *)hVerseForChapter:(NSString *)chapterNo OfBook:(NSString *)book;
+(int)hNumberOfChaptersInBook:(NSString *)book;
//+(NSMutableArray *)hverseForSearchTag:(NSString *)searchTag;
//Bookmarks
+(void)createBookmark:(NSString *)text :(NSString *)book :(NSString *)chapter :(NSString *)verse;
+(NSMutableArray *)getBookmarks;
+(bool)deleteBookmark:(NSString *)book :(NSString *)chapter :(NSString *)verse;

@end

.m

#pragma mark Englisg DB


+(NSMutableArray *)eVerseForChapter:(NSString *)chapterNo OfBook:(NSString *)book
{
    NSMutableArray * result = [[NSMutableArray alloc] init];
    sqlite3 *database;
    NSString *dbpath;
    dbpath = [DbHandler dataFilePath:DbName]; 
    if (sqlite3_open([dbpath UTF8String], &database) == SQLITE_OK)
    {
        NSString *selectSql = [NSString stringWithFormat:@"SELECT [text] FROM english where book = '%@' and chapterNo = '%@'",book,chapterNo];
        sqlite3_stmt *statement;
        if (sqlite3_prepare_v2(database, [selectSql cStringUsingEncoding:NSUTF8StringEncoding], -1, &statement, NULL) == SQLITE_OK)
        {
            while (sqlite3_step(statement) == SQLITE_ROW)
            {
                [result addObject:[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 0)]] ;
            }
            sqlite3_finalize(statement);
        }
        else
        {
            NSLog(@"Sql Preparing Error");
        }
        sqlite3_close(database);
    }
    else
    {
        NSLog(@"Database not opening");
    }
    return result;


}


+(NSMutableArray *)verseForSearchTag:(NSString *)searchTag
{
    NSMutableArray * result = [[NSMutableArray alloc] init];
    sqlite3 *database;
    NSString *dbpath;
    dbpath = [DbHandler dataFilePath:DbName]; 
    if (sqlite3_open([dbpath UTF8String], &database) == SQLITE_OK)
    {
        NSString *selectSql = [NSString stringWithFormat:@"SELECT [text],book,chapterNo,verseNumber FROM english where [text] like '%%%@%%%' limit 0,500",searchTag];
        sqlite3_stmt *statement;
        if (sqlite3_prepare_v2(database, [selectSql cStringUsingEncoding:NSUTF8StringEncoding], -1, &statement, NULL) == SQLITE_OK)
        {
            while (sqlite3_step(statement) == SQLITE_ROW)
            {
                [result addObject:[[NSMutableDictionary alloc] init]] ;

                [[result lastObject] setObject:[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 0)] forKey:@"text"];
                [[result lastObject] setObject:[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 1)] forKey:@"book"];
                [[result lastObject] setObject:[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 2)] forKey:@"chapter"];
                [[result lastObject] setObject:[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 3)] forKey:@"verse"];
            }
            sqlite3_finalize(statement);
        }
        else
        {
            NSLog(@"Sql Preparing Error");
        }
        sqlite3_close(database);
    }
    else
    {
        NSLog(@"Database not opening");
    }
    return result;


}
+(int)hNumberOfChaptersInBook:(NSString *)book
{
    sqlite3 *database;
    NSString *dbpath;
    dbpath = [DbHandler dataFilePath:DbName]; 
    if (sqlite3_open([dbpath UTF8String], &database) == SQLITE_OK)
    {
        NSString *selectSql = [NSString stringWithFormat:@"SELECT count(*) FROM hindi where book = '%@'",book];
        sqlite3_stmt *statement;
        if (sqlite3_prepare_v2(database, [selectSql cStringUsingEncoding:NSUTF8StringEncoding], -1, &statement, NULL) == SQLITE_OK)
        {
            while (sqlite3_step(statement) == SQLITE_ROW)
            {       
                return [[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 0)] intValue];
            }
        }
        else
        {
            NSLog(@"Sql Preparing Error");
        }
    }
    else
    {
        NSLog(@"Database not opening");
    }
    return 0;


}

#pragma mark DB Setup Functions

+(void)createEditableCopyOfDatabaseIfNeeded {
    // First, test for existence.
    BOOL success;
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSError *error;
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:DbName];
    success = [fileManager fileExistsAtPath:writableDBPath];
    if (success) {
        NSLog(@"Database file already exist, so returning...");
        return;
    }
    NSLog(@"CREATING A NEW COPY OF THE DATABASE...");
    // The writable database does not exist, so copy the default to the appropriate location.
    NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:DbName];
    //[fileManager removeItemAtPath:writableDBPath error:nil];
    success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error];
    if (!success) {
        //Some serious problem...
        NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
    }
}

+(NSString *) dataFilePath:(NSString *)path
{ 
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsDirectory = [paths objectAtIndex:0];
    return [documentsDirectory stringByAppendingPathComponent:path]; 
}

@end

and this my tableview code for displaying this db

static NSString *CellIdentifier = @"Cell";

    readCell *cell = (readCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"readCell" owner:self options:nil]; 
        cell = [nib objectAtIndex:0]; 
        cell.malayalamVerse.hidden = YES;
        cell.malayalamVerse.backgroundColor = [UIColor clearColor];
       // self.table.tableFooterView = refreshFooterView;
        //self.table.tableFooterView.userInteractionEnabled = YES;

    }
if(tableView == table)
    {
        UIView *myBackView = [[UIView alloc] initWithFrame:cell.frame];
       // myBackView.backgroundColor = [UIColor colorWithRed:250.0 green:248.0 blue:192.0 alpha:1.0];
        [myBackView setBackgroundColor:[UIColor clearColor]];
        cell.selectedBackgroundView = myBackView;
        [myBackView release];


        cell.textLabel.highlightedTextColor = [UIColor colorWithRed:1 green:1 blue:0.75 alpha:1];
        table.backgroundColor = [UIColor clearColor];
        table.separatorColor = [UIColor clearColor];
        cell.chapterAndVerse.text = [NSString stringWithFormat:@"%@.%d ",delegate.selectedChapter, indexPath.row+1];

        cell.chapterAndVerse.backgroundColor= [UIColor whiteColor];
        cell.chapterAndVerse.textColor = [UIColor brownColor];
        cell.chapterAndVerse.font = [UIFont fontWithName:@"Georgia" size:14.0];
        cell.chapterAndVerse.frame=CGRectMake(33, 6, 30.0, 12.0);
        cell.textLabel.text =  [NSString stringWithFormat:@"            %@",[delegate.allSelectedVerseEnglish objectAtIndex:indexPath.row]];
        cell.textLabel.font = [UIFont fontWithName:@"Georgia" size:18];
        cell.textLabel.textColor = [UIColor darkGrayColor];
        cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
        cell.textLabel.numberOfLines = 0;
        cell.backgroundColor = [UIColor clearColor];

    }

Please help me to do this,If anyone have an idea about this please share with me.
Thanks verymuch.

  • 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-27T13:58:28+00:00Added an answer on May 27, 2026 at 1:58 pm

    This question’s been sitting for a while, so you may already have sorted out the issue.

    You’ve posted quite a lot of code, but if I’m understanding the question the main thing that needs to happen is that in the tableView:cellForRowAtIndexPath: method, the app does something different depending on which language is selected.

    Two approaches:
    Either (1) in the database object (which is pointed at by delegate in your code) have one method for all languages, such as `allSelectedVerse:’. Then, in the database object method, have a test for the language and return the appropriate text.
    Or (2) in the tableView:cellForRowAtIndexPath: method run a test for the selected language and call different methods on the database object accordingly.

    Either way, you’ll need some way of storing the selected language. This could be in the database object or in a singleton used to keep track of settings or in any number of different ways.

    Although (2) is less elegant, it takes less code to illustrate. Assuming the the currently selected language is stored in the database object using an NSString property and assuming that whenever the user changes language you send the tableView a reloadData method, the following code should do the trick. (All this assuming I’ve understood your issue aright in the first place…)

    - (UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
    {
        static NSString *CellIdentifier = @"Cell";
    
        readCell *cell = (readCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil)
        {
           [self configureCellOnFirstCreation: cell]; // farm out configuration
        }
    
      if (tableView == table)
      {
         [self configureCell: cell]; // farm out cell configuration, so the content setting code is more prominent
    
         cell.chapterAndVerse.text = [NSString stringWithFormat:@"%@.%d ",delegate.selectedChapter, indexPath.row+1];
    
         if ([[delegate selectedLanguage] isEqualToString: @"Malayalam"])
         {
           cell.textLabel.text = [NSString stringWithFormat:@"            %@",[delegate.allSelectedVerseMalayalam objectAtIndex:indexPath.row]];           
         }
         else if ([[delegate selectedLanguage] isEqualToString: @"Hindi"])
         {
             cell.textLabel.text = [NSString stringWithFormat:@"            %@",[delegate.allSelectedVerseHindi objectAtIndex:indexPath.row]];
         }
         else // default to English is no matching string found
         {
             cell.textLabel.text = [NSString stringWithFormat:@"            %@",[delegate.allSelectedVerseEnglish objectAtIndex:indexPath.row]];
         }
       }
    
      else
      {
          // handle the other case, e.g. when we're doing search
    
      }
    }
    

    Endnote I think you might get more and faster answers if you can post less code in your questions. In the above, I’ve farmed out configuration to other methods so the code flow that matters is more prominent.

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

Sidebar

Related Questions

I have done a bible application in iphone,there is a last section called database
I am doing a bible reader application for iPhone, I want to implement a
Ha ii,I am doing a Bible application,my requirement is the user write a note
I am doing a reader application,which can sync text to googledoc,i got the working
Doing my first SL4 MVVM RIA based application and i ran into the following
Doing my first tryouts with foreign keys in a mySQL database and are trying
Doing some jquery animation. I have certain divs set up with an attribute of
Doing some 3D stuff in wpf- want to use a simpler test to see
Doing a some practice questions for exam tomorrow can't figure out this one What
Doing some R&D for my company. We are trying to have a listView that

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.