SD Card initialization problem with Mega-CC3000-Camera Shield


I have a Arduino Mega 2560, CC3000 with a SD Card slot and a Camera (VC0703) that came with a shield and a SD card slot with it.

My end goal is that I need to save the captured image on to my laptop.
So one of the approach is to save the picture in the SD card and then send it over WiFi to my laptop.
The problem is that SD card isn't getting initialised sometimes.

if (!SD.begin()) {
    Serial.println("Card failed, or not present");
    // don't do anything more:

About 8 out of 10 times, I get the Card failed, or not present message.

I have been working on some trial and error and tried with pins 10 and 53 as chipSelect pins. Sometimes the card gets initialized when I attempt pin 10 but then the CC3000 doesn't get initialized. For a couple of times the SD.begin() without any input parameters seemed to work. And now I'm pretty fuzzy about how this needs to be done.

I need some guidance in how to give the wiring/how this should be properly done.
Please let me know if I have provided too little information.

Thanks in advance.

I am answering my own question:

I had to set the pin 4 ( SD card chipSelect on the CC3000 Shield) to OUTPUT and digitalWrite it to HIGH.