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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:42:35+00:00 2026-06-16T11:42:35+00:00

I am using using sqlite in my project Previously I had saved image in

  • 0

I am using using sqlite in my project
Previously I had saved image in data but now I am saving image in bytes like following code

NSUInteger len = [entObject.photoImageData length];  
 Byte *byteData = (Byte*)malloc(len);  
 memcpy(byteData, [entObject.photoImageData bytes], len);  
insertString = [NSString stringWithFormat:@"INSERT INTO TBL_COUNTDOWN (DAIRYID,EVENTID,DESCRIPTION,EVENTIMAGE) VALUES (\"%@\",\"%d\",\"No Data\",\"%s\")",self.dairyId,self.eventId,byteData];

For retrieving image I am using following code

NSData *dataForCachedImage = [[NSData alloc] initWithBytes:sqlite3_column_blob(statement, 3) length: sqlite3_column_bytes(statement, 3)];  
                    NSLog(@"dataForCachedImage/getAllEvents is %@",dataForCachedImage);  
                    UIImage *cachedImage = [UIImage imageWithData:dataForCachedImage];  
                    NSLog(@"cachedImage/getAllEvents is %@",cachedImage);

For dataForCachedImage in NSLog I am getting data but for cachedImage I getting null

I dont no whats wrong in my code. Please help me

Thanks in advance

  • 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-16T11:42:36+00:00Added an answer on June 16, 2026 at 11:42 am

    You can save image to document directory and store its path to sqlite database
    save Image code is as follows

     #define DOCUMENTS_FOLDER [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]
    
     // Create a new dated file
     NSDate *now = [NSDate dateWithTimeIntervalSinceNow:0];
     NSString *caldate = [now description];
    
     NSString *filePath= [NSString stringWithFormat:@"%@/%@.jpg", DOCUMENTS_FOLDER,caldate];
     NSURL *url = [NSURL fileURLWithPath:filePath];
    
     UIImage *image = [UIImage imageNamed:@"name.jpg"];
     NSData *imageData = UIImagePNGRepresentation(image);
    
     [imageData writeToFile:filePath atomically:YES];
    

    anytime you want to retrieve Image then get it then use following method to getImage

    - (UIImage*)getImage
    {
     NSString *imagePath = [DOCUMENTS_FOLDER stringByAppendingPathComponent:@"imagename.jpg"];
     UIImage *img = [UIImage imageWithContentsOfFile:imagePath];
     return img;
    }
    

    deleting file

      NSFileManager *fileManager=[NSFileManager defaultManager];
      [fileManager removeItemAtPath:savedFilePath error:nil];
    

    may this will help you..

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

Sidebar

Related Questions

I've been thinking about using SQLite for my next project, but I'm concerned that
I'm using SQLite ( system.data.sqlite v. 1.0.60.0 ) on a Fluent NHibernate project. I
I'm currently thinking of using SQLite as db engine for my C# project, but
I am starting a project from scratch in WPF using SQLite.I want to use
I am using sqlite database for iphone app. but its crash on while loop
I was newbie in using sqlite database android. and now I have a problem
Right now I am using sqlite within a ios application, and I want to
I am using Sqlite on a production server but getting into deadlock scenarios. I
I am using SQLite in a project used by an android application. Currently I
I am using sqlite database mathFActs in my project which i create through Sqlite

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.