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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:07:51+00:00 2026-06-13T17:07:51+00:00

I have created a multi lingual dictionary app which reads several databases , I

  • 0

I have created a multi lingual dictionary app which reads several databases , I have a problem with bookmaring… In the app’s MainViewController I have an action menu which users select dictionaries. so I have created a key for these dictionaries to recognizing which dictionary is selected . Here is my code :

Reading Data Base

- (NSString *) getDBPath
{
    NSInteger kValue = [[[NSUserDefaults standardUserDefaults] stringForKey:@"Bv"] intValue];

    NSString *documentsDir = [[NSString alloc] init];
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
    documentsDir = [paths objectAtIndex:0];


    switch (kValue) {
        case 1:
             documentsDir = [[NSBundle mainBundle]pathForResource:@"eg-pr" ofType:@"sqlite"];
            break;

            case 2:
             documentsDir = [[NSBundle mainBundle]pathForResource:@"pr-eng" ofType:@"sqlite"];
        default:
            break;
    }

    return documentsDir;
}

the problem is I can not bookmark any word on the device !! what is the problem ???

here is dictionary changing function :

- (void)eng_pr
{

    [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:1] forKey:@"Bv"];
    [[NSUserDefaults standardUserDefaults] synchronize];

    dbClass.viewController = self;
    self.searchbar.placeholder = @"Search";
    [myTable reloadData];
}

and bookmarking :

-(void) setBookMark:(NSInteger)oid {

    sqlite3_stmt    *statement;

    const char *dbpath = [[self getDBPath] UTF8String];

    if (sqlite3_open(dbpath, &database) == SQLITE_OK)
    {
        NSString *SetFavSQL = [NSString stringWithFormat: @"UPDATE DIC SET bookmark=1 WHERE id=\"%d\"", oid];
        //      NSLog(@"%@",SetFavSQL);
        const char *SetFav_stmt = [SetFavSQL UTF8String];

        sqlite3_prepare_v2(database, SetFav_stmt, -1, &statement, NULL);
        if (sqlite3_step(statement) != SQLITE_DONE)
        {

        }
        sqlite3_finalize(statement);
        sqlite3_close(database);
    }

}

EDITED :

SEARCHING FUNCTION

- (void)searchWord:(NSString *)txt{

    NSMutableArray *DB_Array = [[NSMutableArray alloc] init];


    NSString *dbPath = [[NSString alloc] initWithString: [self getDBPath]];

    if (sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK) {


        NSString *sql =[NSString stringWithFormat:@"SELECT * FROM DIC Where Name LIKE \'%@%%\' order by NAME LIMIT 30",txt];

        sqlite3_stmt *compiledStatement;

        if(sqlite3_prepare_v2(database, [sql UTF8String] , -1, &compiledStatement, NULL) == SQLITE_OK) {
            while(sqlite3_step(compiledStatement) == SQLITE_ROW) {

                NSInteger oid = sqlite3_column_int(compiledStatement, 0);

                const char* f1 = (const char*)sqlite3_column_text(compiledStatement, 1);
                NSString *oName = f1 == NULL ? nil : [[NSString alloc] initWithUTF8String:f1];

                const char* f2 = (const char*)sqlite3_column_text(compiledStatement, 2);
                NSString *oMean = f2 == NULL ? nil : [[NSString alloc] initWithUTF8String:f2];


                const char* f3 = (const char*)sqlite3_column_text(compiledStatement, 3);
                NSString *oPron = f3 == NULL ? nil : [[NSString alloc] initWithUTF8String:f3];

                NSInteger bm = sqlite3_column_int(compiledStatement, 5);

                readerClass = [[Reader alloc]initWithReadDB:oid Name:oName Mean:oMean Pron:oPron bookMark:bm];

                [DB_Array addObject:readerClass];

            }
        }
        else {
            NSLog(@"Error retrieving data from database.");
        }
        sqlite3_close(database);
    }
    else {

        NSLog(@"Error: Can't open database!");

    }

    AppDelegate *appDelegateClass = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    [appDelegateClass.wordList removeAllObjects];
    [appDelegateClass.wordList=DB_Array mutableCopy];
}
  • 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-13T17:07:52+00:00Added an answer on June 13, 2026 at 5:07 pm

    OK, the problem is that your database (.sqlite) are located in the Resources Folder and all data/files int the resources folder can be read but cannot be written.
    And when you call the bookmark method your do a query (UPDATE …) so it try to modify data in the sqlite and it just can’t because your .sqlite is in the Resources Folder.

    The solution to your problem is to put your .sqlite file in the Document directory and not in the resource directory 😉

    Edit : If I were you, at the first application start, copy all your .sqlite from the Resources folder to the Document folder, and work with the .sqlite located in the Document folder.

    Some useful tips : Copy file from Resources folder to Document folder

    Edit 2:

    When you do this :

    switch (kValue) {
        case 1:
             documentsDir = [[NSBundle mainBundle]pathForResource:@"eg-pr" ofType:@"sqlite"];
            break;
    
            case 2:
             documentsDir = [[NSBundle mainBundle]pathForResource:@"pr-eng" ofType:@"sqlite"];
        default:
            break;
    }
    

    You are reading the files from the Resource folder, you should read the sqlite from the docuemnt directory :

    switch (kValue) {
        case 1:
             documentsDir = [NSString stringWithFormat:@"%@/eg-pr.sqlite", documentsDir];
            break;
    
            case 2:
             documentsDir = [NSString stringWithFormat:@"%@/pr-eng.sqlite", documentsDir];
        default:
            break;
    }
    

    Moreover if kValue is not equals to 1 or 2 the documentDir equals [paths objectAtIndex:0]; (so it will return the Document directory itself and not the sqlite files located in the document directory) does it should be something like that ? :

    documentsDir = [NSString stringWithFormat:@"%@/filename.sqlite", documentsDir];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the best way to design the Domain objects which can have multi-lingual
I have created my own l($text) function in php for a multi lingual website.
I have created a multi-instance performance counter and I pass it mixed case instance
I have created an multi thread application on IIS (ASP.NET MVC), When the threading
I have created a multi module maven project. Now I have shared the project
I have a multi dimensional array, like this: array('name' => array('title'=>'Title','date'=>'Created')) I store it
I have written a multi threaded java code, which when runs creates 8 threads
I'm trying to make my site multi-lingual. I've created 2 folders and 2 files
I have created a class extending SimpleXMLElement which loads an XML containing translations for
I have created multi colum list. In each list there is a div inside

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.