I have prepared a reusable component for sqlite, the same can be used as it is by making SVN-LINK to your into your project.
Common Database class includes the basic functionality of Accessing SQLite database, It contain different function that perform different operation on SQLite database.Main functions available in this class are Insert, delete, update record in the database, get total number of record in the table, check for duplication of record in the table and get record list from the table.
–> With resolving memory leaks
When you execute select query from your class. At that time you need to use retain for your resulted Array
DataArr = [[ [Database shareDatabase] SelectAllFromTable:@”Select No,Name,Mobile from TestTbl”] retain ];
–> Resolve the crash issue for read Special character percentage(%) from Database
–> Include new function for getting sum of any column records.
You can use this class in your application just by passing your Query as an argument of function. Main functions included in this class are listed below.
- (void)Insert:(NSString )query
- (void)Delete:(NSString *)query
- (void)Update:(NSString *)query
- (BOOL)CheckForRecord:(NSString *)query
- (int)getCount:(NSString *)query
- (NSMutableArray *)SelectAllFromTable:(NSString *)query
First time when you launch application at that time this method is useful for copy database from application bundle to your Application Document Directory.
For Getting Database Path use below method
- (NSString *) GetDatabasePath:(NSString *)dbName
For Programming and understanding flow of coding you can go through:
Code Link:- Database.h Sample Code
This class includes declaration of all objects and methods used in application.
Code Link:- Database.m Sample Code
This class includes definition of all methods and main logic for Database Operation.