Solved

Delete images from camera roll

Posted on 2010-09-23
1
2,776 Views
Last Modified: 2013-11-25
How can you delete phones from the camera roll in xcode?
0
Comment
Question by:BTMExpert
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 33

Accepted Solution

by:
pgnatyuk earned 500 total points
ID: 33751037
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question