Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone Documents directory and UIFileSharingEnabled, hiding certain documents

I want the user to be able to access the files in the documents directory but am using core data and dont want the user to be able to access the store (the sqllite db), can i hide it from the user while still allowing file sharing, or can i put it in another directory where it will still get backed up?

like image 900
Aran Mulholland Avatar asked May 31 '10 10:05

Aran Mulholland


People also ask

Can you hide files in files on iPhone?

There is an easy way to hide files and folders from the Files iOS app. Just put a "." as the first character of your file name. It will protect the access to those files while using the Files app.


2 Answers

The answer given by FrenchKiss Dev is not correct. The user will still be able to see the ".data" directory in iTunes and save that locally with all the files inside it.

Instead, store private documents in Library/Preferences

According to Apple:

In addition to the directories documented previously, the entire /Library directory has always been preserved during updates and backups, except for /Library/Caches. Because of this, applications can create their own directories in /Library/ and those directories will be preserved in backups and across updates. To minimize the risk of name collisions, we recommend that you name this directory carefully. For example, a directory named Private Documents would be a good choice. You should store any files you don't want to share to Library/Preferences.

like image 99
memmons Avatar answered Sep 19 '22 11:09

memmons


In the documents directory, create a subdirectory which name starts with a dot. For example:

.data

EDIT: Please stop downgrading this answer !
This answer was correct at the time (remember that it was before the iPad was actually available! And there was a lot of confusion on the matter, we were still hoping for the iPad to appear in the shared devices in the Finder...).
Today (April 2012) it is still working on the Mac but not on Windows (starting a directory name with a dot means nothing in Windows).

Anyway, this Shared Document feature is a mess. Later they fixed it by saying that "Private Documents" should be stored in the Library Folder not in the Documents folder. But remember that developers were already using the Document folder before the iPad came.
Don't blame me for Apple mistakes.
Stack Overflow should have a way to mark an answer as obsolete.
API changes, get fixed, and it renders answers obsolete.

like image 28
FKDev Avatar answered Sep 20 '22 11:09

FKDev