Wednesday, July 16, 2014

How to Share an Image Tweet on Twitter in BackGround in iOS Simple method


- (void)shareTwitterImage:(UIImage *)image withMessage:(NSString *)sharedMsg
{
    ACAccountStore *accountStore = [[ACAccountStore alloc] init];
    ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
    
    [accountStore requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error)
     {
         if(granted)
         {
             NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];
             
             if ([accountsArray count] > 0)
             {
                 ACAccount *twitterAccount = [accountsArray objectAtIndex:0];
                 
                 TWRequest *postRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:@"https://upload.twitter.com/1/statuses/update_with_media.json"] parameters:[NSDictionary dictionaryWithObject:sharedMsg forKey:@"status"] requestMethod:TWRequestMethodPOST];
                 
                 [postRequest addMultiPartData:UIImagePNGRepresentation(image) withName:@"media" type:@"multipart/png"];
                 [postRequest setAccount:twitterAccount];
                 
                 [postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
                  {
                      //show status after done
                      NSString *output = [NSString stringWithFormat:@"HTTP response status: %i", [urlResponse statusCode]];
                      NSLog(@"Twiter post status : %@", output);
                  }];
             }
         }
     }];
}



Tuesday, July 15, 2014

How to Get Twitter Profile information From iPhone Settings in iOS


-(void)getTwitterSettingsInfo
{
    ACAccountStore *accountStore = [[ACAccountStore alloc] init] ;
    
    ACAccountType *twitterAccountType =  [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
    NSArray *twitterAccounts = [accountStore accountsWithAccountType:twitterAccountType];
    if([twitterAccounts count] > 0)
    {
        ACAccount *twitterAccount = [twitterAccounts objectAtIndex:0];
        
        NSString *twitterUserName = twitterAccount.username;
        twillterUserLabel.text = twitterUserName;
        
        if(twitterIdentifier == 10) //Getting iamge if Identfier = 10
        {
            NSError *error;
            NSString * requestString = [NSString stringWithFormat:@"https://api.twitter.com/1.1/users/show.json?screen_name=%@", twitterUserName];
            NSURL *verify = [NSURL URLWithString:requestString];
            NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:verify];
            [[PFTwitterUtils twitter] signRequest:request];
            NSURLResponse *response = nil;
            NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
            
            if ( error == nil){
                NSDictionary* result = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];
                NSLog(@"%@",result);
                
                NSString * requestString = [result objectForKey:@"profile_image_url_https"];
                
                NSURL *url = [NSURL URLWithString:requestString];
                NSData *imageData = [NSData dataWithContentsOfURL:url];
                [profilepicButton setBackgroundImage:[UIImage imageWithData:imageData] forState:UIControlStateNormal];
                twitterIdentifier = 0;
            }
        }
        
    }
    else
        twillterUserLabel.text = @"Undefined";
    


}

How to Get Facebook Profile information from iPhone Settings in iOS Simple way


-(void)getFacebookSettingInfo
{
    ACAccountStore *accountStore = [[ACAccountStore allocinit] ;
    ACAccountType *facebookAccountType =  [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
    NSArray *facebookAccounts = [accountStore accountsWithAccountType:facebookAccountType];
    //  NSLog(@"facebookAccounts ==== >>> %@", facebookAccounts);
    if([facebookAccounts count] > 0)
    {
        // ACAccount *facebookAccount = [facebookAccounts objectAtIndex:0];
        NSMutableArray *faceBookAccount = [facebookAccounts objectAtIndex:0];
        NSMutableArray *facebookProperties =  [faceBookAccount valueForKey:@"properties"];
        
        //NSLog(@"===== %@",facebookProperties);
        NSString *facebookName = [facebookProperties valueForKey:@"ACPropertyFullName"];
        fbUserLabel.text = facebookName;
        
        NSString *facebookID = [facebookProperties valueForKey:@"uid"];
        
        if(fbIdentifier == 10) //Gettin Image if identifer = 10
        {
            NSString *imageUrl = [[NSString allocinitWithFormat@"http://graph.facebook.com/%@/picture?type=large", facebookID];
            NSURL *url = [NSURL URLWithString:imageUrl];
            NSData *imageData = [NSData dataWithContentsOfURL:url];
            [profilepicButton setBackgroundImage:[UIImage imageWithData:imageData] forState:UIControlStateNormal];
            fbIdentifier = 0;
        }
        
        
    }
    else
        fbUserLabel.text = @"Undefined";



}

Thursday, May 29, 2014

Simple way to Share Images from iOS App to Facebook and Twitter - One method for both

sharing Image in social sites (Facebook and Twitter)....first import social,facebook,twitter frameworks


/To share the final image on twitter
-(void)shareImageToTwitter
{
    [self shareImage:savedImage withText:nil onSocialSite:SLServiceTypeTwitter];
}

//To share the final image on facebook
- (void)shareImageToFacebook
{
    [self shareImage:savedImage withText:nil onSocialSite:SLServiceTypeFacebook];
}

here "savedImage " was sharing image


//Common method to share image on twitter & facebook
-(void)shareImage :(UIImage *)postImage withText :(NSString *)message onSocialSite :(NSString *const )socialSiteType
{
    SLComposeViewController *socialSiteComposer=[SLComposeViewController composeViewControllerForServiceType:socialSiteType];
    if([SLComposeViewController isAvailableForServiceType:socialSiteType])
    {
        SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){
           
            [socialSiteComposer dismissViewControllerAnimated:YES completion:nil];
           
            switch(result)
            {
                case SLComposeViewControllerResultCancelled:
                default:
                {
                    NSLog(@"Cancelled.....");
                }
                    break;
                case SLComposeViewControllerResultDone:
                {
                    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"" message:@"Posted successfully" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                    [alertView show];
                }
                    break;
            }};

        //Add content to post
        [socialSiteComposer setInitialText: message];
        NSData *data = UIImageJPEGRepresentation(postImage, 1.0);
        [socialSiteComposer addImage:[UIImage imageWithData:data]];
       
        [socialSiteComposer setCompletionHandler:completionHandler];
        [self presentViewController:socialSiteComposer animated:YES completion:nil];
    }
    else
    {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Sorry!" message:@"You can't post right now, make sure you have at least one account setup" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
    }
}

Monday, February 24, 2014

How to set Header View of UItableview To stick at the top in iOS

//To stick the header to the Table view
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    CGFloat sectionHeaderHeight = 50;
    if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0)
    {
        scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
    } else if (scrollView.contentOffset.y>=sectionHeaderHeight)
    {
        scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
    }

}

Friday, January 24, 2014

How to set Navigation Bar font style and font through out application in iOS


    in App delegate


    [[UINavigationBar appearance] setTitleTextAttributes:
     [NSDictionary dictionaryWithObjectsAndKeys:
      
      [UIColor blueColor], UITextAttributeTextColor,
      
       [UIColor greenColor], UITextAttributeTextShadowColor,
      
      [NSValue valueWithUIOffset:UIOffsetMake(-3, 3)], UITextAttributeTextShadowOffset,
      
      [UIFont fontWithName:@"Futura-CondensedMedium" size:20.0], UITextAttributeFont,
      

      nil]];

Navigation Bar Bagground image

  UINavigationBar *navBar =[[self navigationController] navigationBar];

     [navBar setBackgroundImage:[UIImage imageNamed:@"topbar_bg.png"forBarMetrics:UIBarMetricsDefault];

Thursday, January 9, 2014

How to Customize UIActionSheet buttons in iOS

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet  // before animation and showing view
{
    //To Grayed out Cancel button if there is no loaded image
    for (UIView* view in [actionSheet subviews])
    {
        if ([[[view class] description] isEqualToString:@"UIAlertButton"])
        {
            if ([view respondsToSelector:@selector(title)])
            {
                NSString* title = [view performSelector:@selector(title)];
                
                if ([title isEqualToString:@"Cancel"] && [view respondsToSelector:@selector(setEnabled:)])
                {
                    if(imageView.image == nil)
                    {
                        view.backgroundColor = [UIColor grayColor];
                        view.alpha = 0.5;
                    }
                }
            }
        }
    }

}

http://stackoverflow.com/questions/743636/iphone-disabling-uiactionsheet-buttons

How to COMBINE / MERGE two images into ONE image in iOS



// combine/ merge two images into one image

- (UIImage*)imageByCombiningImage:(UIImage*)firstImage withImage:(UIImage*)secondImage
{
    UIImage *image = nil;
    
    CGSize newImageSize = CGSizeMake(MAX(firstImage.size.width, secondImage.size.width), MAX(firstImage.size.height, secondImage.size.height));
    if (UIGraphicsBeginImageContextWithOptions != NULL) {
        UIGraphicsBeginImageContextWithOptions(newImageSize, NO, [[UIScreen mainScreen] scale]);
    } else {
        UIGraphicsBeginImageContext(newImageSize);
    }
    [firstImage drawAtPoint:CGPointMake(roundf((newImageSize.width-firstImage.size.width)/2),
                                        roundf((newImageSize.height-firstImage.size.height)/2))];
    [secondImage drawAtPoint:CGPointMake(roundf((newImageSize.width-secondImage.size.width)/2),
                                         roundf((newImageSize.height-secondImage.size.height)/2))];
    image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    return image;

}

Monday, January 6, 2014

How to Show / Hide the tabbar controller in iOS






#pragma mark ==== Show / Hide the tabbar controller =====
//Show TabBar
+ (void) hideTabBar:(UITabBarController *) tabbarcontroller
{
    [self showHideTabBar:tabbarcontroller withDuration:0.25 xPosition:270];
}
//Hide TabBar
+ (void) showTabBar:(UITabBarController *) tabbarcontroller
{
   [self showHideTabBar:tabbarcontroller withDuration:0.2 xPosition:-270];
}

//Common method to Show / Hide TabBar
+ (void) showHideTabBar:(UITabBarController *) tabbarcontroller withDuration :(NSTimeInterval )duration xPosition :(float)xPos
{
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:duration];
    float fHeight = screenRect.size.height;
    ifUIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation) )
    {
        fHeight = screenRect.size.width;
    }
    
    for(UIView *view in tabbarcontroller.view.subviews)
    {
        //NSLog(@"%@",view);
        if([view isKindOfClass:[UITabBar class]])
        {
            [view setFrame:CGRectMake(view.frame.origin.x+xPos, fHeight-49, view.frame.size.width, view.frame.size.height)];
        }
        else
        {
            [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fHeight)];
            view.backgroundColor = [UIColor whiteColor];
        }
    }
    
    [UIView commitAnimations];
}


How to get Underlined text attributeString Like set on email label, Multiple Colors on label

#pragma mark ==== Underlined text attributeString too set on email, addres labels =====
+(NSMutableAttributedString *)underLinedText :(NSString *)normalString
{
    NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithString:normalString];
    [attributeString addAttribute:NSUnderlineStyleAttributeName
                            value:[NSNumber numberWithInt:1]
                            range:(NSRange){0,[attributeString length]}];
    
    return attributeString;

}

//To use this attributeString

  textLabel.attributedText = [Self underLinedText: @"http://www.gmail.com"] ;


For Multiple Color Use


 [attributeString addAttribute:
NSForegroundColorAttributeName 

                                  value: [UIColor redColor] 
                                  range: NSMakeRange(10, 1)];

How to customize UI SearchBar in iOS

#pragma mark=======To set BGs for searchBar=======
+(void)customizeSearchBar :(UISearchBar *)searchBar;
{
    //To add backfround color to the SEARCH BAR & SEARCH FIELD
    searchBar.backgroundImage = [UIImage imageNamed:@"clearColor.png"];
    [searchBar setSearchFieldBackgroundImage:[UIImage imageNamed:@"search_bar.png"] forState:UIControlStateNormal];
    
    //To remove search icon and change the position of the cursor
    UITextField *textfield=(UITextField*)[[searchBar subviews] objectAtIndex:1];
    textfield.leftView=  [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"clearColor.png"]];
    
    //To change font color of searche text & place holder
    for(UIView *subView in searchBar.subviews)
    {
        if([subView isKindOfClass:UITextField.class])
        {
            //Searched Font
            [(UITextField*)subView setTextColor: [UIColor colorWithRed:83/255.0f green:44/255.0f blue:27/255.0f alpha:1.0f] ];
            //Place holder
            [(UITextField*)subView setValue:[UIColor colorWithRed:83/255.0f green:44/255.0f blue:27/255.0f alpha:0.5f] forKeyPath:@"_placeholderLabel.textColor"];
        }
    }
    

}

Push To NextView in STORY BOARD


-(IBAction)pushToNextView:(id)sender
{
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    
ListOfValuesViewController *listOfValues = (ListOfValuesViewController *)[storyboard instantiateViewControllerWithIdentifier:@"ListOfValues"];
   

    listOfValues.selectedArray = selectedArray;
  

    [self.navigationController pushViewController:listOfValues animated:YES];

NotificationCenter

Using Notification You can Make Interact Two Classes.
In ClassA You Need To Register Your Notification By Using Lines Of Code
In ClassA.h
-(void)getNotification:(NSNotification *)notify;
In ClassA.m File
-(void)viewDidLoad
{
......
  [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(getNotification:) name:@"Notification_Name" object:nil];
.....
}
# pragma mark Get Notification
-(void)getNotification:(NSNotification *)notify
{
    NSLog(@"Notify User info %@",notify.object);
    Array1 = notify.object;
}



To Post Notifcation From ClassB You Need To Write The Following Lines Of Codes
ClassB.m File

After Completing Required Action You Have Post Notification

-(IBAction)doneButton:(id)sender
{
      [[NSNotificationCenter defaultCenter] postNotificationName:@"Notification_Name" object:selectedArray userInfo:nil];
}

Friday, January 3, 2014

SQLite Programing : Initial Steps

Add libsqlite3.0.dylib Framework to you Xcode project.

Create an SQlite Table  SqliteTable  using SQLite manager.

Add a new File of NSObject class DBFieldsDict for your columns.


//
//  DBFieldsDict.h
//  SQlite
//
//  Created by Prasad on 7/9/13.
//  Copyright (c) 2013 Prasad. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface DBFieldsDict : NSObject

// TABLE Meeting
@property (nonatomic, assign) int Meeting_Id;
@property (nonatomic, copy) NSString *Meeting_Title;
@property (nonatomic, copy) NSString *Meeting_Information;
@property  (nonatomic, assign) int  Meeting_day;
@property  (nonatomic, assign) int  Meeting_time_start;
@property  (nonatomic, assign) int  Meeting_time_end;


// TABLE Directors
@property (nonatomic, assign) int Director_Id;
@property (nonatomic, copy) NSString *Director_name;
@property (nonatomic, copy) NSString *Director_Organization;
@property (nonatomic, copy) NSString *Director_Organization_Role;
@property (nonatomic, copy) NSString *Director_Bio_Info;
@property (nonatomic, copy) UIImage *Director_image;

@synthesize all columns in DBFieldsDict.m


Create Another NSObject class  "DataBase" for Database Queries




in DataBase.h File
#import <Foundation/Foundation.h>
#import <sqlite3.h>
#import "DBFieldsDict.h"

@interface DataBase : NSObject

+ (NSString*) copyDBFile;

+ (NSMutableArray*) select Meeting InformationFromDB;
+ (NSMutableArray*) selectDirectorsFromDB;

@end





in DataBase.m File

#import "DataBase.h"

@implementation DataBase


//Commen method for DAtaBase Copy
+ (NSString*) copyDBFile
{
    NSString *docsDirectoryPath;
    NSArray *dirPaths;
    NSString *databasePath;
    NSFileManager *fileManager = [NSFileManager defaultManager];
    
    // Get the documents directory
    dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    docsDirectoryPath = [dirPaths objectAtIndex:0];
    // Build the path to the database file
    databasePath = [[NSString alloc] initWithString: [docsDirectoryPath stringByAppendingPathComponent: @"SqliteTable.db"]];
    
    BOOL isSuccess = [fileManager fileExistsAtPath: databasePath ];
    
    if (!isSuccess)
    {
        NSError *error;
        NSString *defaultDBPath=[[NSBundle mainBundle]pathForResource:@"SqliteTable" ofType:@"db"];
        // NSLog(@"path :%@", defaultDBPath);
        isSuccess = [fileManager copyItemAtPath:defaultDBPath toPath:databasePath error:&error];
        
        if (! isSuccess)
            NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
    }
    
    NSLog(@"%@",databasePath);
    
    return databasePath;
    
}



//To Return Notnull String to avoid crashes
+(NSString *)notNullsqlite3_column_textOfColumn :(int)columnNo squliteStatement:(sqlite3_stmt*)statement
{
    NSString *coumnText =  ((char *)sqlite3_column_text(statement, columnNo)) ? [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, columnNo)] : nil;
    
    if(coumnText == nil)
    {
        return @"";
    }
    else
    {
        return  [NSString stringWithUTF8String:(const char*) sqlite3_column_text(statement, columnNo)];
    }
}



Select Query

//select Directors FromDB
+ (NSMutableArray*) selectDirectorsFromDB
{
    NSString *DBPath = [self copyDBFile];
    sqlite3 *sqliteDB = nil;
    sqlite3_stmt *statement = nil;
    NSMutableArray *allDataArray = [[NSMutableArray alloc] init];
    
    
    if (sqlite3_open([DBPath UTF8String], &sqliteDB) == SQLITE_OK)
    {
        
        //Prepare Query to retrieve data
        NSString *query =  @"SELECT Director_Id, Director_name , Director_Organization , Director_Organization_Role , Director_Bio_Info , Director_image    FROM Directors";
        
        if(sqlite3_prepare_v2(sqliteDB, [query UTF8String], -1, &statement, NULL) == SQLITE_OK)
        {
            while (sqlite3_step(statement) == SQLITE_ROW)
            {
                DBFieldsDict *dbFieldsDict = [[DBFieldsDict alloc] init];
                
                
                //To get data in to dbFieldsDict
                
                //For Integer Data
                dbFieldsDict.Director_Id = sqlite3_column_int(statement, 0);
                
                
                //For VArChar String Data
                dbFieldsDict.Director_name  = [self notNullsqlite3_column_textOfColumn:1
                                                                     squliteStatement:statement];
                
                dbFieldsDict.Director_Organization  = [self notNullsqlite3_column_textOfColumn:2
                                                                             squliteStatement:statement];
                
                dbFieldsDict.Director_Organization_Role  = [self notNullsqlite3_column_textOfColumn:3
                                                                                  squliteStatement:statement];
                
                dbFieldsDict.Director_Bio_Info  = [self notNullsqlite3_column_textOfColumn:4
                                                                         squliteStatement:statement];
                
              
                //For Image Data
                NSData *imageData = [NSData dataWithBytes:sqlite3_column_blob(statement, 2)
                                                           length: sqlite3_column_bytes(statement, 2)];
                dbFieldsDict.Director_image  = [UIImage imageWithData:imageData];
                

                
                //To add the all data from dicts to the Array
                [allDataArray addObject:dbFieldsDict];
            }
        }
        else
        {
            NSLog(@"Statement not prepared");
        }
    }
    return allDataArray;
}









Insert Query
+ (BOOL) insertCoordinatesIntoDB:(DBColumns*)dbColumns
{
    
    NSString *DBPath = [self copyDBFile];
    sqlite3 *contactsDB = nil;
    sqlite3_stmt *insertStatement = nil;
    // NSLog(@"DICT : %@", contact);
    if (sqlite3_open([DBPath UTF8String], &contactsDB) == SQLITE_OK)
    {
        if(insertStatement == nil)
        {
            // CREATE TABLE "LatLangTable" ("CompanyName" VARCHAR, "Lattitude" FLOAT, "Langitude" FLOAT)
            
            NSString *insertQuery = [NSString stringWithFormat:@"INSERT INTO LatLangTable ( CompanyName, Lattitude, Langitude) VALUES(?, ?, ? )"];
            const char *insert = [insertQuery UTF8String];
            
            NSLog(@"-------- %@",insertQuery);
            
            if(sqlite3_prepare_v2(contactsDB, insert, -1, &insertStatement, NULL) != SQLITE_OK)
            {
                NSLog(@"Error while creating insert Statement");
            }
            else
            {
               sqlite3_bind_text(insertStatement, 1, [dbColumns.companyName2 UTF8String], -1, SQLITE_TRANSIENT);
                
                sqlite3_bind_double(insertStatement, 2, dbColumns.latitude);
                sqlite3_bind_double(insertStatement, 3, dbColumns.longitude);

//To insert Date

 sqlite3_bind_double(insertStatement, 2, [dbColumns.ResultentTime timeIntervalSince1970]);

                
            }
        }
        
        
        
        if(SQLITE_DONE != sqlite3_step(insertStatement)) {
            NSLog(@"Error while Executing insert Statement");
        }
    }
    return YES;
    
}


//Calling insert Query from our view

-(IBAction)insertLatLang:(id)sender
{
    
    //Add latitudes, longitudes to dictionary to coordinatesArray
    for (int i= 0; i<addreessArray.count; i++)
    {
        CLLocationCoordinate2D center =  [self geoCodeUsingAddress: [addreessArray objectAtIndex:i]];
        
        dbColumns = [dataArray objectAtIndex:i];
        
        DBColumns *dbCol = [[DBColumns alloc] init];
        
        dbCol.companyName2 = dbColumns.companyName1;
        dbCol.latitude = center.latitude;
        dbCol.longitude = center.longitude;
        



          [DataBase insertCoordinatesIntoDB:dbCol];
        
    }
    
}






















//Update statement for update  recent contacts by time
//====================================
+ (BOOL) updateRecentRecord:(Recent*)recent
{
      NSString *DBPath = [self copyDBFile];
      sqlite3 *contactsDB = nil;
      sqlite3_stmt *updateStatement = nil;
      if (sqlite3_open([DBPath UTF8String], &contactsDB) == SQLITE_OK)
      {
            if(updateStatement == nil)
            {
                  NSString * updateQuery = [NSString stringWithFormat:@" UPDATE RecentsTable SET NAME = ? , recentRowId = ?, time = ? where recentRowId = ?"];
                  const char *update = [updateQuery UTF8String];
                  
                  if(sqlite3_prepare_v2(contactsDB, update, -1, &updateStatement, NULL) != SQLITE_OK) {
                        NSLog(@"Error while creating update Statement");
                  }
                  else 
                  {
                        sqlite3_bind_text(updateStatement, 1, [recent.Name UTF8String], -1, SQLITE_TRANSIENT);
                        sqlite3_bind_int(updateStatement, 2, recent.recentRowId);
                        sqlite3_bind_double(updateStatement, 3, [[NSDate date] timeIntervalSince1970]);
                        sqlite3_bind_int(updateStatement, 4, recent.recentRowId);
                  }
                  
                //  NSLog(@" Nane- %@  recentID-%d ",recent.Name, recent.recentRowId );
                  
                  if(SQLITE_DONE != sqlite3_step(updateStatement)) {
                        NSLog(@"Error while Executing update Statement");
                  }
            }
      }
      
      [DBPath release];
      return YES;
}











//To Delete the selecte contacts from db
//==================================

+(BOOL)deleteContactFromDB:(Contact*)contact
{
      NSString *projectPath=[self copyDBFile];
      BOOL returnValue = YES;
      sqlite3_stmt *deleteStmt = nil;
      sqlite3 *cuisineDB = nil;
      
      if (sqlite3_config(SQLITE_CONFIG_SERIALIZED) == SQLITE_OK) {
            NSLog(@"Can now use sqlite on multiple threads, using the same connection");
      }
      int ret = sqlite3_enable_shared_cache(1);
      if(ret != SQLITE_OK)
      {
          //  NSLog(@"Not Shared");
      }
      // Open the database. The database was prepared outside the application.
      if (sqlite3_open([projectPath UTF8String], &cuisineDB) == SQLITE_OK)
      {
            if(deleteStmt == nil
            {
                  
                  //  int selectedId = [[dict objectForKey:@"rowid"] intValue];
                  int selectedId = contact.rowid;
                  
                  NSString *strValue = [NSString stringWithFormat:@"DELETE FROM ContactInfo WHERE (rowid = '%d') ", selectedId];
                  const char *sql = [strValue UTF8String];
                  
                  if(sqlite3_prepare_v2(cuisineDB, sql, -1, &deleteStmt, NULL) != SQLITE_OK) {
                        NSLog(@"Error while creating addStmt in addRecipeToDatabase %@", [NSString stringWithUTF8String:(char *)sqlite3_errmsg(cuisineDB)]);
                        returnValue = NO;
                  }
            }
            
            if(SQLITE_DONE != sqlite3_step(deleteStmt)) {
                  NSLog(@"Error while Executing addStmt in addRecipeToDatabase %@", [NSString stringWithUTF8String:(char *)sqlite3_errmsg(cuisineDB)]);
                  returnValue = NO;
            }
            
            sqlite3_reset(deleteStmt);
            
            if (deleteStmt)
            {
                  sqlite3_finalize(deleteStmt);
                  deleteStmt = nil;
            }
      }
      sqlite3_close(cuisineDB);
      [projectPath release];
      
      return returnValue;
      
}