• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2809
  • Last Modified:

Delete images from camera roll

How can you delete phones from the camera roll in xcode?
0
BTMExpert
Asked:
BTMExpert
1 Solution
 
pgnatyukCommented:
I do not know how to delete the photo's programmatically.
(But everybody knows how to save.)
iPhone  app has access to the files in its sandbox.
Can you save the images in the application document folder? So then you can delete it using the standard file manager?

NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,  YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:name];

NSError *error = nil;
if( [fileManager fileExistsAtPath:fullPath] )
        [fileManager removeItemAtPath:fullPath error:&error] );

Here is a blog post with save and remove code:
Using NSFileManager to save an image to or load/remove an image from documents directory
http://www.friendlydeveloper.com/2010/02/using-nsfilemanager-to-save-an-image-to-or-loadremove-an-image-from-documents-directory-coding/

More about file operations on iPhone:
iPhone File System: Creating, Renaming and Deleting Files
http://iphonedevelopertips.com/data-file-management/iphone-file-system-creating-renaming-and-deleting-files.html

Maybe, you can find something in the open source iphone browsers?
http://code.google.com/p/iphonebrowser/downloads/list
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now