How to access the iPhone application directory and store image files there

I want to know if I can access the directory where my application is installed. I also want to create a subdirectory in the same directory in order to save all the images that I captured in my application. I also want to view images using the default iPhone to view images. It can be done?

+6
objective-c iphone cocoa-touch
source share
6 answers
NSString *appFolderPath = [[NSBundle mainBundle] resourcePath]; NSFileManager *fileManager = [NSFileManager defaultManager]; NSLog(@"App Directory is: %@", appFolderPath); NSLog(@"Directory Contents:\n%@", [fileManager directoryContentsAtPath: appFolderPath]); 
+13
source share

You can get the document folder of the application

 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 a document folder or even store them in a temp folder.

+7
source share

If you want to access the application on the simulator, go to this directory:

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

If you want to access the application on the device, it becomes a little more complicated. First, connect your iOS device to iTunes and backup your phone (with encryption disabled). Then download this application: iPhone / iPod Touch Backup Extractor , find your package ID and click on extract. Then the application will receive all the data for you. I am sure that this is not in real time, but it does the job!

+4
source share

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

+1
source share

To store any of your own files, you will have to use the Documents directory, as Girish already said. But if you need to display images that you shot using the camera, the only way to display them using the UIImagePickerController (default image viewer) is to specify the type of source when initializing it as a saved photo album.

0
source share

C'mon, this is all in the sample code and documentation. In fact, this is even one of the frequently asked questions in the iPhone Dev Center. I refuse to give an answer. Instead, here's a link: It's easy to find documentation that answers your question

-8
source share

All Articles