file browser in iphone? - iphone

I am new to Iphone.How to create file browser in iphone ?
I wish to show all the files and folders in the iphone.How to do this?

Unless you are on a jailbroken phone, your app can only access files within its own "sandbox".
There are three folders your app can access, which contain data specific to your application. Your app will not be able to access file data outside these folders.
With that caveat in mind, you would likely use:
NSFileManager and NSDirectoryEnumerator to build a data source to a table view
UITableView to present the list of files and folders obtained from step 1
UINavigationController to provide a navigation stack for walking through a hierarchy of folders: a stack of UITableView instances
to browse the list of accessible files and folders within your application's sandbox.

If you are producing this for the App Store, I would suggest against exposing such a control even for your application's data. It violates the Human Interface Guidelines and most likely will be rejected.
From the iPad Human Interface Guidelines:
Although iPad applications can allow
people to create and manipulate files,
this does not mean that people should
have a sense of the file system on
iPad.
On iPad, there is no application
analogous to the Mac OS X Finder, and
people should not be asked to interact
with files as they do on a computer.
In particular, people should not be
faced with anything that encourages
them to think about file types or
locations, such as:
An open or save dialog that exposes a file hierarchy
Information about the permissions status of files

Related

Swift Document Picker Directory URL

I implemented the UI Document Picker to select files from iCloud Drive, local storage etc. and it all works fine so far.
As we all know it is possible to also select files from apps like Dropbox, OneDrive etc. but for a user who does not know this is possible, the document picker can be quite confusing.
Is it possible to implement a button to directly open the Dropbox Folder (or any other), instead of having to navigate trough the document directorys?
Apple provides a functionality like directoryURL but im not sure if this works, especially if a user might not have installed an app like Dropbox or so.
I don't want to navigate to another app or use frameworks for this. I just want to programmatically change the starting point when opening the Document Picker to show files of external apps. It would be nice if it is also possible to check if an app is available/installed so that a button can be shown or not depending on that.
Picture: Storages of external apps accessible with document picker

Is there a path every app can write files in the jailbreak iPhone?

I should hook UIResponder of every app, including SpringBoard and any others. In the hooking, I will write something to the specified file. If I set the path to /var/mobile/Library/MyApp, recommended by Cydia, I found that only the SpringBoard and MyApp could write successfully.
So is there a place every app can write and read?
I admit that I'm not 100% sure on this one, but my guess would be no, there is not a path that every app can writes files to on a jailbroken iPhone.
Certainly, jailbreak apps (installed in /Applications/) on a jailbroken phone can write to locations that can be shared between those jailbreak apps. But, as I understand your question, you would like to inject code into normal, App Store apps, so that those apps can also read and write to the shared location. That part I don't think is possible, because jailbreaking does not completely disable the sandbox for 3rd-party apps installed normally, under /var/mobile/Applications/.
Now, there might be a workaround. There are some shared folders that are accessible to all apps for certain purposes. For example, any app can write images to the saved photos album. What you could try is to take the content of the file you want to write, and encode it as fake image data, in a UIImage (e.g. with [UIImage imageWithData:]). You'd probably need to add a valid image header to the data. Then, you save the file to the photos album, using something like
writeImageToSavedPhotosAlbum:orientation:completionBlock:.
Another app could then find the fake photo by enumerating the saved photos album, and then converting the asset back to image representation to pull the real data back out.
However, this seems quite complicated, and possibly wouldn't work (I haven't tried it). Perhaps you could tell us why you want this shared file. Maybe there's a better way to share the data, without using a globally-accessible file?
Notifications can help you with this. Every app will send interprocess notifications about the events. You could start a daemon that will listen for this notifications and save them in a file. Or you could listen for them in SpringBoard as he can write, for example, to /var/mobile/Media. Depends on what you want to do with this file. Check out my answer here How to create a global environment variable that can be accessed by SpringBoard or other applications in the jailbroken iPhone?

Is there any limit of file size in the Document of IOS app

I want to write a app to download and manage files from the web.If I just put the file in the Document. Is there any limit of file size or can I load another app to read the file in the Directory?
I don’t think there is a limit to how big a file you can put in your app’s Documents directory other than the amount of free space left on the device.
No, other apps cannot access the contents of your app’s Documents directory—that’s the entire purpose of the sandboxing system. What you can do is use the UIDocumentInteractionController class with a file you’ve downloaded to present the user with a list of apps that can handle opening that file.
The filesystem would limit the size to 4G, but im sure the iOS limits it even further.
No two apps can see each others files, unless the user export/import them via iTunes, or you set the app to be in the list of options when you hold down the link and the "Open In..." popup appears.
Check out the UIDocumentInteractionController Reference.
And UIActionSheetDelegate Reference.

What methods are available to view files on iPhone?

I am working on a hobby app which accesses the dropbox api and allows users to browse the directory structure (mimicking the Dropbox iPhone app).
My current challenge is to be able to view the files on the device. What is my best way of doing this? There are obviously a large range of file types and I would like to be able to view as many as possible. Further to this, does anyone know how to implement 'Open with' functionality that displays a list of compatible apps that can be opened to view the file externally.
Typical file types will include (but are not limited to)
PDFs
Images
Documents
Spreadsheets
Presentations
Video files
Audio files
Plain text
I understand that I may have to use different view controllers depending on the file type, but am sure that I have read before that there is a special view controller that can handle a lot of these file types. Just cannot find it for the life of me.
Also, I think I can use a UIWebView for a lot of the file types - though this seems like more of a work around than a definitive solution.
Before people ask, I am not intending to release this to the app store, but am trying to replicate the Dropbox app functionality for educational reasons.
Thanks
UIDocumentInteractionController, available on iOS 3.2 and upwards, is the way to do the "Open with" type functionality:
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIDocumentInteractionController_class/Reference/Reference.html#//apple_ref/occ/cl/UIDocumentInteractionController
The iOS application programming guide is the place I normally flick through to find things like that:
http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/StandardBehaviors/StandardBehaviors.html#//apple_ref/doc/uid/TP40007072-CH4-SW22

How can you access a set of photos with the iPhone SDK?

I know that I can access the camera or show the image picker to the user, but what if I just wanted to pick 10 photos, randomly, from the images stored on the device with no user interaction?
Using UIImagePickerController gives me the ability to use the camera or the image picker, but how can I do this automatically, without user interaction?
AFAIK there is no way of accessing any files from any Apple app (or any other app for that matter) unless you use one of the classes provided by the SDK.
I once wrote a simple browser app that starts at / and populates a UITableView with the contents of the directory. It let me see what directories I could access, and what files I could access within those directories. If you can find what you're looking for, help yourself to it's directory contents. Otherwise, it may be hidden from you, inaccessible from your application's sandbox.