Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access iPhone application directory and store image files there

I want to know whether I can access the directory where my application is installed. Also I want to create a sub directory in the same directory to store all the images I capture in my application. I further want to view the images using iPhone's default image viewer. Can this be done?

like image 886
Neo Avatar asked Feb 05 '09 14:02

Neo


3 Answers

NSString *appFolderPath = [[NSBundle mainBundle] resourcePath];

NSFileManager *fileManager = [NSFileManager defaultManager];  
NSLog(@"App Directory is: %@", appFolderPath);
NSLog(@"Directory Contents:\n%@", [fileManager directoryContentsAtPath: appFolderPath]);
like image 179
pjb3 Avatar answered Nov 18 '22 12:11

pjb3


You can get the Document folder of the app

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder

You can create Folder and files using NSFileManger. You can store files in document folder or even you can store it in temp folder.

like image 8
Girish Kolari Avatar answered Nov 18 '22 12:11

Girish Kolari


If you want to access the app on the simulator, navigate to this directory:

~/Library/Application Support/iPhone Simulator/User/Applications

If you want to access the app on a device it gets a little trickier. First, plug your iOS device into iTunes and backup the phone (with encryption turned off). Then download this app: iPhone / iPod Touch Backup Extractor, find your bundle ID and click extract. The app will then get all the data for you to see. Sure it's not real time but does the job!

like image 4
ingh.am Avatar answered Nov 18 '22 12:11

ingh.am