I found an ultimate method to share files among apps on iPad(also iPhone)

0 comments

Background
The illusion we get from promotions about iPad is that it's easier to produce documents simply from an iPad. True it's easy, but apple seems to mess up the file sharing among apps and among devices. We need to share files among apps because some application has features that another doesn't have. For example, some applications are easy to download/upload files but not a good reader/editor, while some are vice versa.

Yes Apple provides development tools for programmers to send files to another app, or for users to directly access Documents directory under the application's own directory through iTunes. However they are still handicapped in the following aspects:
1. Files are not organizes. Our working files are spread in several apps and some are duplicated with different versions. It's a nightmare that every time We have to recall which app holds the latest file we edited, and if we have lots of documents, we have to scan through the files to find the exact one.
2. Waste storage space. As mentioned above, sending files to another application is to make a copy to the applications's own directory. So we waste the storage saving two or more copies in our iDevice, while Apple charge a lot for more storage spaces.

So, the ultimate solution to the above problem is to let all regular iApplications see one shared directory. If they can share the same directory, there is no more duplicated files and we can organize files in it once and for all! I have come up with an elegant way to solve this, and is simple, but it needs to be done in jailbroken devices. However I believe it's theoretically doable in non-jail broken iDevices. But I guess Apple will never allow this method or app legally working in our devices. (though they can consider providing more flexible file sharing now)

Problem
So I want all my applications to be able to see a shared directory.

Solution
The simplest way, after jailbreaking, is to utilize the Unix link (alias in Mac os, or shortcut in Windows), to redirect applications to our shared directory. So which directory is shared among all regular iApplications and is both readable and writable? I can only find one, the shared photo album directory, in /var/mobile/Media/DCIM.
The idea is to create a directory, say CrossAppDocs, in the shared directory, and create links in the document directory in every application you want to be accessible to the shared directory. So here are two methods:

Method
Method #1. Using iFile(Cydia)'s Graphical interface: (To be simple I don't tediously list every tiny step)
a. Browse to /var/mobile/Media/DCIM
b. Tap Edit and then '+' to create a new directory, naming it CrossAppDocs. Change the Group permission to be readable and writeable. Tap Create to save.
c. Now you are still in directory edit mode. Select the directly just created and tap the icon in the lower right corner to 'copy/link'
d. Tap Done to finish editing.
e. Browse to /var/mobile/Applications and go to applications you want to link to CrossAppDos.
f. Go to Documents directory and tap Edit again and tap the same lower right icon. Chose 'create link', and you finish creating a link to the sharing documents!


Method #2: using terminal/SSH
1. Go to /var/mobile/Media/DCIM
2. mkdir CrossAppDocs
3. Since you login as root, you have to change the ownership:
- chmod 775 CrossAppDocs
- chown mobile CrossAppDocs
4. Go to document directory in applications you want to link: /var/mobile/applications/(some hash code)/Documents
5. Type: link -s /var/mobile/Media/DCIM/CrossAppDocs ./CrossAppDocs
So you finish creating a link to the sharing document.

Result Images:

GoodReadersLite sees CrossAppDocs


Downloads Lite sees CrossAppDocs




Discussion
Note that some applications have different schemes about their usage of document directory. You may need to add the link in their subdirectories.

Adding a link in the document directory for each app is just one solution using the unix link feature. You can even try changing the document directory into a link to one folder in your shared documentation folder, if the application cannot read/write files in the subdirectories in document folder.
Here are a list of applications working very well:
- iBooks (only shows PDF)
- GoodReader
- Office2
- iAnnotate
- Downloads
- FileBrowser(in data sub-directory)
- Files
- PrintCentral
And more you can imagine

Unfortunately the iWorks products are currently not working well with this scenario because they do not see subdirectories in Documents. The only way but not recommended is that you turn the document directory itself into a link to the shared folder.

So how iTunes backup sees the links? I don't know. But it seems that iTunes doesn't complain. Maybe it simply backs up the link.

More advanced, can we add a link in app's document directory without jailbreaking? Itunes now supports file uploading since iOS 3.2 and also in iOS 4.0, so I am wondering somehow we can send a link created locally to our iDevices. But directly uploading a link does not work. Can it be done through some iTunes API?

This article is just a beginning idea of cross-application file sharing. If you have more advanced ideas, pleases feel free to leave your comments.