how can i do Limit the file app size in ipad? - iphone

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 in the Directory?
can any one help me..
thanks in advance.

Just a warning with the introduction of iOS5 saving large files or files that can be regenerated into the documents directory is frowned upon (actually you were never meant to do it but its only being enforced now). This is because the files in the documents directory get backed up to iCloud and you obviously do not want to fill that up. Apple have started rejecting apps just for this reason.
You should now place the downloaded files into the temp or cache directories. But also be aware that the OS will clear these directories when running low on memory so you need to have logic in you app to check if the files exist and re-download if they do not.

No real limit except the device and other user data. Still best to be frugal.

Related

how many images can I cache in my iPhone app?

I'm wondering how many images I can store in the iPhone documents directory so that I don't get any memory issues. I'm torn between caching images or loading them from a webserver every time the user wants to access them. There most likely won't be more than 10-20 images cached at any given time...
Any thoughts?
There's a 2GB cap on the largest size of a single file in the /Documents folder. Other than that, you can store as many images as you want. iOS itself didn't put a limitation on how much space you can use on a device. So your space limit is the size of Flash on the device (i.e. 16GB, 32GB etc).
You might consider use the /Library/Caches instead because iCloud will attempt to sync the Documents folder (if entitlements are configured). I heard App being rejected by review for excessive use of the Documents folder. To get the path, call NSSearchPathForDirectoriesInDomains with NSCachesDirectory and NSUserDomainMask.
Though a user can determine the size of space you are occupying in System Settings.
You can probably cache as many files as available memory allows, but you absolutely should be safe having 10 - 20 images cached at any given time.
B.T.W., instead of using the documents directory, why not consider using the cache directory as He (+1 to him!) suggests?
Here is a related question that shows how to get the size of the directory.

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.

Does the iPhone / iPod touch cache data also on disk, or only in memory?

I am not sure, but I think I was reading a while ago that iPhone / iPod Touch don't cache anything to disk. They cache only in memory. So cache is not persistet when app quits. After relaunch of app it will re-fetch the data from the net. Is that true?
iPhone OS disables on-disk caching from NSURLCache on this platform. If you need on-disk caching support anyway, you can use http://github.com/rs/SDURLCache which gives back on-disk cache support on iPhone OS
You can explore this yourself using the iPhone Simulator, opening a terminal or using the Finder, and going to `~Library/Application Support/iPhone Simulator/User/Applications/ then opening whatever directory your application is in.
You'll see a Documents directory, a Library and a tmp directory.
I've never looked to see if UIWebView is caching anything, but I know that Core Data will.
If you just suck down data yourself using CFNetwork, I believe it's up to you to cache the data yourself by saving it to tmp or Documents if you want.
tmp will not get backed up by the iTunes Sync process, but Documents will, so don't use Documents for temporary cache. Otherwise you'll just waste space and slow down sync backups.
The Documents directory will persist through anything, including app upgrades, except outright deleting the application using the Springboard or doing a total device storage wipe.
Actually the Library directory has directories. called Cache, WebKit/LocalStorage, and Preferences. So that would suggest something or the other.
Don't write to the application bundle directory or bad things could happen.
iPhone apps can write data to disk.

Is Library/Caches cleared automatically by the iPhoneOS?

I have an app that will need to cache some images.
I have read some documentation about caching, and the logical thing to do is to cache my images within the Library/Caches directory within my app's sandbox.
I understand that the reason for storing caches images here are:
Library/Caches isn't backed up by iTunes
Library/Caches is cleared periodically by the OS
That second point is what I'm questioning...
Is this true?
Does the OS clear the caches directory automatically?
Will I need any of my own logic to detect if the cache is too big and to clear the oldest items?
I found this in the documentation:
Use this directory to write any application-specific support files that you want to persist between launches of the application. Your application is generally responsible for adding and removing these files. However, iTunes removes these files during a full restore of the device so you should be able to recreate them as needed. To access this directory, use the interfaces described in “Getting Paths to Application Directories” to get the path to the directory.
In iPhone OS 2.2 and later, the contents of this directory are not backed up by iTunes.
http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/FilesandNetworking/FilesandNetworking.html

iPhone programming: How much data can I store in my app's Documents Directory (root folder)?

The reason I ask is my app lets users cache map tiles. Does anyone know the real cap on how much data I can let them store?
You can store as much as you want until you run out flash. Having said that, your users probably won't like it if you start eating all of the space on the phone.
Also, make sure you put it in the Cache folder, as opposed to Documents. The Documents folder gets backed up when you sync to iTunes, the Cache folder is not. If you have a ton of data in the Documents folder it will massively slow down iTunes synching.
About a year ago the word was there is a 2Gb limit on app size, but you'll be hard pressed to find an "official" declaration of such, even on apple's site or the discussion forums there
That being said 2Gb is pretty hearty for a mobile app, caching and all
I'm not aware of any quota for apps using the writable area, but it would be easy enough to check.