Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In my opinion Save imagePath in SQLite, and save image in your document directory. I do the same. May be this help you.</p> <pre><code>-(void)saveDataToDatabase:(NSString *)fileNameToSave { NSString *docsDir; NSArray *dirPaths; dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); docsDir = [dirPaths objectAtIndex:0]; sqlite3_stmt *statement; NSString *databasePath = [[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent: @"scanner.db"]]; NSLog(@"%@",databasePath); const char *dbpath = [databasePath UTF8String]; if (sqlite3_open(dbpath, &amp;databaseHandle) == SQLITE_OK) { NSString *insertSQL = [NSString stringWithFormat: @"Insert into IMAGEINFO (NAME,IMAGEPATH) values ('%@','%@')",@"imageFirst",fileNameToSave]; const char *insert_stmt = [insertSQL UTF8String]; sqlite3_prepare_v2(databaseHandle, insert_stmt, -1, &amp;statement, NULL); if (sqlite3_step(statement) == SQLITE_DONE) { [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"database"]; } else { } } } -(void)saveImage:(NSString *)fileName:(UIImage *)imageToSave { NSError *error; NSString *fileNaToSave = [NSString stringWithFormat:@"Documents/%@.png",fileName]; NSString *pngPath = [NSHomeDirectory() stringByAppendingPathComponent:fileNaToSave]; // Write image to PNG [UIImagePNGRepresentation(imageToSave) writeToFile:pngPath atomically:YES]; // Let's check to see if files were successfully written... // You can try this when debugging on-device // Create file manager NSFileManager *fileMgr = [NSFileManager defaultManager]; // Point to Document directory NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; // Write out the contents of home directory to console NSLog(@"Documents directory: %@", [fileMgr contentsOfDirectoryAtPath:documentsDirectory error:&amp;error]); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload