Search This Blog

Saturday, 15 December 2012

How to get the call details from PhoneListener

So here is the one how to get the call details and send it to somewhere on remote database.


As i mentioned earlier how to integrate PhoneListener:

here are the functions to over ride in Phone Listener , you may override any function as the name suggests when these functions will be called...
Create these variables in class:
PhoneCall _phoneCall;
String _phoneNumber;
int _callduration;

first add your phone listener:


ii  am getting call details when the call is incoming....

_phoneCall = Phone.getCall(CallID);
    _phoneNumber = _phoneCall.getDisplayPhoneNumber();

Now as you can see i am just getting the details here nothing else;

in CallDisconnected function:
_callDuration = _phoneCall.getElapsedTime();
//Call function to send data to server.....use invokeLater for this ...


Wednesday, 12 December 2012

Address Book fetching-iOS

Hello friends,
                so here is something new,if you wana give your users an option to select a contact from contact list , here is the code then.


First add two frameworks to your project:

Now simply in your view.header file where you want to provide this option, import below...

#import <AddressBookUI/AddressBookUI.h>

And, also add this delegate method:

ABPeoplePickerNavigationControllerDelegate  in your header file

now simply , do this whether on button click or anywhere...

   ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc]init];
    picker.peoplePickerDelegate = self;
    [self presentModalViewController:picker animated:YES];

Override these below functions  as :

-(void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker{
    [self dismissModalViewControllerAnimated:YES];

-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person{
    [self displayPerson:person];
    [self dismissModalViewControllerAnimated:YES];
    return NO;

-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{
    return NO;

And here is the display person function:

        NSString* name = (__bridge_transfer NSString*)ABRecordCopyValue(person,kABPersonFirstNameProperty);
       //name string value contains the first name of contact as in contact list
        NSString* phone = nil;
        ABMultiValueRef phoneNumbers = ABRecordCopyValue(person,kABPersonPhoneProperty);
        if (ABMultiValueGetCount(phoneNumbers) > 0) {
            phone = (__bridge_transfer NSString*)
            ABMultiValueCopyValueAtIndex(phoneNumbers, 0);
        } else {
            phone = @"[None]";
       //phone string contains the selected contact's phone number.


Monday, 3 December 2012

How to use Filters on TextField in Blackberry

Hello friends,
                   Here it is how to use filters on TextFields in Blackberry.


Supose we have a TextField "_ph"...

We want to display a numeric keyboard for this obviously....
So here it is....

_ph = new TextField(TextFilter.NUMERIC);

there are lots of options like email,Hexadecimal,Integer,IP etc...


Thursday, 29 November 2012

How to handle the navigation click in blackberry

Hello friends,
                Here it is , in my previous post i told you about doing something on touchevents on any i am giving you the code which will handle click events on anyfield whether touch screen or no touch device....

Suppose we have a bitmapfield which we want to use as a button...we have two png's "abc.png" and for rollover we have "abcR.png"

So here it goes....


First we initialize the bitmap field like this...

BitmapField _button;

in construstor:

 _button = new BitmapField(){
public int getPreferredWidth(){
return 22;
public int getPreferredHeight(){
return 21;
public boolean isFocusable(){
return true;
public void onUnfocus(){
protected void drawFocus(Graphics graphics, boolean on) {
      XYRect focusRect = new XYRect();
           if (on) {
            graphics.setDrawingStyle(Graphics.DRAWSTYLE_FOCUS, true);
            graphics.drawBitmap(focusRect.x, focusRect.y, focusRect.width, focusRect.height,Bitmap.getBitmapResource("abcR.png"), 0,0);
//           this.setBitmap(Bitmap.getBitmapResource("help_rollover.png"));
public void layout(int maxWidth,int maxHeight){
super.layout(getPreferredWidth(), getPreferredHeight());


Now we will override the navigation click function and identify the field and do some action there:

public boolean navigationClick(int status,int time){
Field _focus = this.getLeafFieldWithFocus();
if(_focus instanceof BitmapField){
BitmapField _bitmap = (BitmapField)_focus;

//Do something....
return true;
return false;

Thsi will make your bitmap clickable whether its a touch event on that bitmap field on its a trackpad click....but only when this bitmap is in focus.....

Ask for any queries....

Friday, 16 November 2012

How to change the selectedRow textColor in tableView for xcode

Hello friends,
                 Here it is a simple but sometimes useful for how to change the text color on row selection in TableView for xcode:


In function:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{


Do this :
cell.textLabel.textColor = [UIColor white Color];
cell.textLabel.highlightedTextColor = [UIColor blackColor];

 cell.detailTextLabel.textColor = [UIColor grayColor];
cell.detailTextLabel.highlightedTextColor = [UIColor redColor];

here what will happen , on initial loading the color for textLabel and detail text Label will be white and gray respectively,on selecting the row the color will change to black for textLabel and red for detailTextLabel.

Ask for any queries....

Thursday, 8 November 2012

Get Battery Level and temperature in Blackberry.

        Below is the code,for getting batteryLevel and battery temperature in Blackberry:


int _batteryLevel = DeviceInfo.getBatteryLevel();
int _batteryTemp  = DeviceInfo.getBatteryTemperature();


Wednesday, 7 November 2012

How to hide Keyboard in Blackberry

 Here is the simple one liner without explanations:



Thursday, 1 November 2012

CustomChoiceField for blackberry

Hello ,
  Here is the Class for custom choice field in blackberry.Credits to perumal_n on blackberry forums:

import net.rim.device.api.ui.DrawStyle;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Ui;
import net.rim.device.api.ui.component.ObjectChoiceField;
import java.lang.String;
import net.rim.device.api.ui.XYRect;
import net.rim.device.api.ui.Font;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Field;

//import org.utility.DSConstants;

public class CustomChoiceField extends ObjectChoiceField {

private int _bgWidth = 110;
private int _bgHeight = 30;
private boolean _hasFocus = false;
String[] m_Choices;
private int m_ChoiceFieldWidth;
private int m_TextMarginRight = 5;
private int m_TextMarginLeft = 5;
private Bitmap DopDownImgOn, DopDownImgOff;
private Font FONT_PLAIN;
private String visibleText;
private int m_MarginTop;

public CustomChoiceField(String label, String[] choices, int initialIndex) {
super(label, choices, initialIndex,CustomLongChoiceField.FIELD_RIGHT);
m_Choices = choices;

DopDownImgOff = Bitmap.getBitmapResource("dropdown_s.png");
DopDownImgOn = Bitmap.getBitmapResource("dropdown_off_s.png");
FONT_PLAIN = Font.getDefault().derive(Font.PLAIN, 5, Ui.UNITS_pt);

Font currFont = Font.getDefault().derive(Font.PLAIN, 3, Ui.UNITS_pt);
for (int i = 1; i < choices.length; i++) {
if (m_ChoiceFieldWidth < currFont.getAdvance(choices[i]))
m_ChoiceFieldWidth = currFont.getAdvance(choices[i]);
m_ChoiceFieldWidth += m_TextMarginLeft + m_TextMarginRight;

public int getPreferredHeight() {
return _bgHeight;

public int getPreferredWidth() {
return _bgWidth;


protected void layout(int width, int height) {
if (m_ChoiceFieldWidth == 0) {
m_ChoiceFieldWidth = width;
_bgHeight = height;
super.layout(width, height);
setExtent(_bgWidth, _bgHeight);

protected void onFocus(int direction) {
_hasFocus = true;
// super.onFocus(direction);

public void setBusiness(String[] choices) {
this.m_Choices = choices;

protected void onUnfocus() {

_hasFocus = false;
// super.onUnfocus();

protected void paint(Graphics g)

// DopDownImg = Bitmap.getBitmapResource("scroll.PNG");

if (DopDownImgOn instanceof Bitmap) {

m_MarginTop = (DopDownImgOn.getHeight() - FONT_PLAIN.getHeight()) / 4;
visibleText = (getSelectedIndex() == -1 || getSelectedIndex() >= m_Choices.length) ? ""
: m_Choices[getSelectedIndex()];

if (_hasFocus == false) {
g.drawBitmap(0, 0, DopDownImgOff.getWidth(), DopDownImgOff
.getHeight(), DopDownImgOff, 0, 0);
} else {
g.drawBitmap(0, 0, DopDownImgOn.getWidth(), DopDownImgOn
.getHeight(), DopDownImgOn, 0, 0);

g.drawText(visibleText, m_TextMarginRight, m_MarginTop,
DrawStyle.ELLIPSIS, DopDownImgOn.getWidth() - 30);

// g.pushContext(clip, xOffset, yOffset);

// g.popContext();


Use your own images ....and youmay find the problems in DSConstants.Just used to know the device model.....omit this if you want.


Tuesday, 30 October 2012

Hide Keyboard in xcode

       find the code for hiding keyboard on click of return.

For textField:

-(BOOL)textFieldShouldReturn:(UITextField *)textField{
 [textfield resignFirstResponder];

for TextView:

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
    if([text isEqualToString:@"\n"]) {
          [textView resignFirstResponder];
    return YES;

Include delegate for UITextField and UITextView

Monday, 29 October 2012

"HTTP Connection" in blackberry

Hello ,
         So this was something awkward i encountered , my app was working fine on BB simulator but on device it keeps giving me HTTP Connection error.

       I checked my code many times but it was perfect , so i myself tried something that will sound awkward as the problem is.What i did is i switched off the device pull out the battery ...waited for atleast 10 seconds...put battery back restart the device connect it to system and debug my app ....and it is working fine now ....dont ask me the reason , i just sorted out the problem i myself don't know whats wrong before ...

Happy Programming....

Monday, 24 September 2012

How to integrate camera in xcode

Hello friends,
               Long time na???? actually i dint do anything new in these last days i surely made sketch book for kids on iPhone but not something great....apart from all that , here it is a simple yet useful code for you....


start camera on button click:

In a button click function :

UIImagePickerController * imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
[self presentModalViewController:imagePicker animated:YES];
Remember i m not releasing the imagePicker as i use ARC in my projects ...
Now get the image captured in UIImage...override this function and remember 
to mention UIImagePickerControllerDelegate in your header file..
- (void)imagePickerController:(UIImagePickerController *)picker 
didFinishPickingMediaWithInfo:(NSDictionary *)info {
    UIImage * image = [info objectForKey:UIImagePickerControllerEditedImage];

    // You have the image. You can use this to present the image in the 
       next view like you require in `#3`.

    [self dismissModalViewControllerAnimated:YES];
Ask for any queries.....
This can lead you to new ideas....sorry for being selfish i can't tell
 you my idea, but presently i m using this simple thing to make something 
that never comes to itunes before.

Monday, 17 September 2012

How to know when a webview finish loading a page in xcode

Hello friends,
                its been a long time since i posted, so here it is a new one you will find awkward solutions for this as using some "theguide" 3rd party API and all but it is as simple as a button in xcode......i was working on it and i thought why dont we use webviewdelegate for this and i found it it is

Step 1:

Include UIWebViewDelegate in your header file:

Step 2:

And,then over ride this function in your .m file:

-(void)webViewDidFinishLoad:(UIWebView *)webView{
    //Do Something

this function will be called when a WebView finish loading a page , you can do anything in it.....Remeber to set the webview delegate to self.

Monday, 10 September 2012

How to use Push Notification in xcode

Hello friends,
                   sorry for being lazy, but i m going to provide the link with complete tutorial for how to use Push notification in your app......


ASk me if you face any problem implementing it....

Sunday, 26 August 2012

How to use Multithreading to fetch data in xcode and prevent ur app from freezing

Hello Friends,
                       It was strange that i used it before , but in an interview i was asked about Lazy loading...and i was stupid enough and thought it is something new i never ever used....Actually what it means is to load your data usng a different thread and not in main thread to prevent your app from freezing this is what they call ...LAZY LOADING!!! ....Here is the code to run a separate thread from main thread and you can do your data fetching and other bulky work in these threads and your app will remain working as it is ...and display the data once it is available...


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [loading setHidden:NO];
    [loading startAnimating];
    [warning setHidden:NO];
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
      AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication]delegate];
    radioStations.userInteractionEnabled = NO;
    favButton.userInteractionEnabled = NO;
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *add1URL = @"";
        NSString *add2URL = @"";
        NSString *add3URL = @"";
        NSData *data1 = [NSData dataWithContentsOfURL:[NSURL URLWithString:add1URL]];
        NSData *data2 = [NSData dataWithContentsOfURL:[NSURL URLWithString:add2URL]];
        NSData *data3=    [NSData dataWithContentsOfURL:[NSURL URLWithString:add3URL]];
        app.addimg1 = [UIImage imageWithData:data1];
        app.addimg2 = [UIImage imageWithData:data2];
        app.addimg3 = [UIImage imageWithData:data3];
    [loading stopAnimating];
    app.preScreen = @"All";
    UIStoryboard *story = self.storyboard;
    NSString *url = (NSString *)[urls objectAtIndex:indexPath.row];
    player = [story instantiateViewControllerWithIdentifier:@"Radioplayer"]; = (NSString *)[station objectAtIndex:indexPath.row];
    player.title = url;
    app.genre = cell.detailTextLabel.text;
    [self presentViewController:player animated:YES completion:nil];

I used the simplest way for non confusing example here, i am running a different thread as you can see this thread will keep running in background and fetch the images whereas my main thread will keep running and push the player view on screen

Ask for any queries there are lot of tutorials on web but i found them confusing the basic concept is this only.....that you run a different thread fetch data and when the data will b available ,it will b shown on display that's it for now....SIGNING OFF!!!

Saturday, 25 August 2012

Change UIAlertView Background in xcode

Hello masters,
                       I found this link including the complete project for custom alert the developer says it works but i run this project on simulator and still i am getting that stupid blue background above the developers defined image ....try it if anyone can get it worked may be it will work fine on real device i dint test it on real leaving it on you ...update me if anyone got it worked and share with of Luck!!!

Here is the link :

Friday, 24 August 2012

How to change the UIAlertView FontColors and FontStyles in xcode

Hello Friends,
                     As in morning today i was trying to do something that is changing the looks of AlertView that my app displays , but as far as i worked with xcode4.2 their is no way i found to change the default blue color of the standard AlertView or may be i did something wrong ..... ;P but somehow i worked and successfully changed the font styles and colors of text shown in AlertView ,here is the code .....


First of all you have to include UIAlertViewDelegate in your view's .h file like below:



Noe over ride the below function in your view's .m file

-(void)willPresentAlertView:(UIAlertView *)a;ertView{
UILabel *title = [alertView valurForKey:@"_titleLabel"];
title.font = [UIFont fontWithName:@"Arial" size:18];
[title setTextColor:[UIColor whiteColor];

UILabel *body = [alertView valueForKey:@"_bodyTextLabel"];
body.font = [UIFont fontWithName:@"Arial" size:15];
[body setTextColor:[UIColor whiteColor];

That it , whenever your this view present a AlertView this function will be executed.....try different font styles and size....but remember there is no way to change the background as far as i worked on it i succeed in displaying a image but that was below that blue no Luck!

Thursday, 23 August 2012

How to use UIActionSheet in xcode

Hello Friends,
                     Today, i am giving you something good to prevent your user doing things accidentally - the answer is UIActionSheet ,a very good option to ask user if he is sure or anything.
Follow the code :


Suppose you have a viewController,in viewController.h file do something like this we are including UIActionSheetDelegate here like implementing interfaces in java :

@interface Home:UIViewController<UIActionSheetDelegate>



Now,Suppose you have a button and you want to ask your user if he/she is sure? Do something like this on your viewController.m file:

UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle: @"Are You Sure?" delegate:self cancelButtonTitle:@"NO" destructiveButtonTitle:@"YES" otherButtonTitles:nil,nil];

[actionSheet showInView:self.view];


Now you are supposed to override a function that is :

-(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex{

if(!buttonIndex==[actionSheet cancelButtonIndex]){
//do something on click of 'YES'.



ask for any queries

Wednesday, 22 August 2012

Zoom Effect for UILabel in xcode

Hello Friends,
                       Here is another one a zoomEffect like the one you see in slide show , simple yet useful follow the code:


In your viewController.h :

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController{
    IBOutlet UILabel *label;
@property(retain,nonatomic)IBOutlet UILabel *label;

In viewController.m :

NSInteger i=0;
double fontsize;

- (void)viewDidLoad
    [super viewDidLoad];
    fontsize = 0;
// Do any additional setup after loading the view, typically from a nib.
    [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(zoomer) userInfo:self repeats:YES];
    label.font = [UIFont fontWithName:@"Arial" size:fontsize];

    label.font = [UIFont fontWithName:@"Arial" size:fontsize];

I assume you know how to make connections between Storyboard elements and IBOutlets:

ask for any queries:

Tuesday, 21 August 2012

How to use JSON in xcode

Hello Friends,
                  Here is the simple twitter example to fetch public tweet from  a url which is providing data n JSON Format .


fetchedData is a function i am using to fetch the data from twitter URL and saving it in a NSArray tweets:

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@""]];
        NSError *error;
        tweets = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
        dispatch_async(dispatch_get_main_queue(), ^{
            [self.tableView reloadData];
                UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Error" message:@"Request Limit Reached." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
                [alert show];

Now below i am fetching the data by defining keys for object and using it as a cell text:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellIdentifier = @"TweetCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    NSDictionary *tweet = [tweets objectAtIndex:indexPath.row];
    NSString *text =[tweet objectForKey:@"text"];
    NSString *name = [[tweet objectForKey:@"user"]objectForKey:@"name"];
    cell.textLabel.text = text;
    cell.detailTextLabel.text = [NSString stringWithFormat:@"by %@",name];
    return cell;

How to use this:

Just call fetcheddata method in your viewDidLoad method , it will fetch the data from url and JSONSerialization will serialize it and save it in an Array.

Next what we are doing in cellForRowAtIndexPath is , we are fetching the values for particular keys from the Array in which we have saved the Data in a serialized form and finally we are using that data in different ways....

Ask for any queries....

Where to find Radio Streaming url's for xcode

Hello friends,
                  As this is a matter of fact , and as i observed most of the developers are interested to develop radio app for iphone but they still dont know where to find the url's for radio stations....Actually this post does'nt include any code.....I just want to tell you that where you can get the url's .....go to ....there you just have to right click the radio station name and click copy link location and thts it you get the url for that radio station follow my previous post for playing that radio url in iPhone.

How to calculate distance between two GeoLocations in Blackberry

Hello Friends,
                        Here is the simplet yet useful trick to calculate distance between two geolocations ....I have an idea in my mind and a simple straight answer to android's newest feature ....just wait and watch....nothing to loose in trying.....I am coming up with something Big for BB.


Suppose you have cordinates a and b:

Coordinates A = new Coordinates(43.99,-80.71,float.NaN);
Coordinates B = new Coordinates(34.21,-76.43,float.NaN);

float distance = A.distance(B)/1000;

Done....Try this....

Monday, 20 August 2012

How to change cell Background and SelectionView in TableView for xcode

Hello Friends,
                      Here is a code to use any image for tableView's cell Background and selection View,Follow the code:


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
    UIView *selectionView = [[UIView alloc]initWithFrame:cell.bounds];
    [selectionView setBackgroundColor:[UIColor colorWithRed:0.875 green:0.004 blue:0.004 alpha:1] ];
    UIImageView *CellBack = [[UIImageView alloc]initWithFrame:cell.bounds];
    [CellBack setImage:[UIImage imageNamed:@"transparent.png"]];//transparent.png is a image that i wana use as a cell background

    cell.backgroundView = CellBack;
    cell.backgroundColor = [UIColor clearColor];
        cell.textColor = [UIColor whiteColor];
    cell.selectedBackgroundView = selectionView;
    cell.selectedTextColor = [UIColor whiteColor];

    cell.textLabel.text=[station objectAtIndex:indexPath.row];
    if([genre objectAtIndex:indexPath.row]!=NULL){
    cell.detailTextLabel.text =[NSString stringWithFormat:@"Genre: %@", [genre objectAtIndex:indexPath.row]];
        arrow = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 30, 30)];

Thursday, 16 August 2012

How to check for the duplicate entry in sqlite database when inserting a value in database for xcode

Hello Friends,
                      Here it is a complete function to check if the value is already inserted to database and prevent ur app from inserting duplicate entries in databsae.


    sqlite3_stmt *statemnt;
    AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication]delegate];
    const char *dbPath = [app.databasepath UTF8String];
    if(sqlite3_open(dbPath, &database)==SQLITE_OK){
        NSString *checkSQL = [NSString stringWithFormat:@"SELECT stationName,stationURL FROM FAVOURITESTATION WHERE stationName=\"%@\" ",];// is a value for which i am checking if it already exists in sqlite database or not.
        const char *chkSQL = [checkSQL UTF8String];
        if(sqlite3_prepare_v2(database,chkSQL, -1,&statemnt,NULL)==SQLITE_OK){

                return YES;

                return NO;
    return NO;

follow preivous post for complete refrence of variables used here....

How to Create a sqlite database programmatically in xcode 4.3 with storyboard

Hello Friends,
                      So still making those sqlite databases in some sqliteManager and copy them to device on first you ever think that made a duplicate database that is the one in you app ....and its useless as you app is using the one which is copied from app to device?? why making fuss and using memory uselessly??? is the code to create database programmatically in xcode....


In AppDelegate.h declare a NSString variable as follows:

@interface AppDelegate : UIResponder <UIApplicationDelegate>{
NSString *databasePath;
@property(retain,nonatomic)NSString *databasepath;


In AppDelegate.m file do something like this:

@synthesize databasepath;

And the View where you want to create database do this:
- (void)viewDidLoad

  NSString *documentdir;
    NSArray *documentPaths;
    documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    documentdir = [documentPaths objectAtIndex:0];
    app.databasepath = [[NSString alloc]initWithString:[documentdir stringByAppendingPathComponent:@"favourites.db"]];
    NSFileManager *fileManager = [NSFileManager defaultManager];
    if([fileManager fileExistsAtPath:app.databasepath]==NO){
        const char *defaultPath = [app.databasepath UTF8String];
        if(sqlite3_open(defaultPath, &database)==SQLITE_OK){
            char *errMsg;
            const char *create_Query = "CREATE TABLE IF NOT EXISTS FAVOURITESTATION(stationName TEXT,stationURL TEXT)";
            if(sqlite3_exec(database, create_Query, NULL, NULL, &errMsg)!=SQLITE_OK){
                UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"JUKEBOX" message:@"Failed to create Table." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
                [alert show];
            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"JUKEBOX" message:@"Failed to create Database." delegate:self cancelButtonTitle:@"OK"otherButtonTitles:nil, nil];
            [alert show];
        fileManager = nil;

Happy Programming...;) ask for any queries..