The Local Storage module was created to provide our access to the device local disk. The following article will describe how to use local cache of an app.
What files can I save / load from app local cache? - Any files you want.
Will those files be avaliabe on other user devices? - No. Files you save locally are only avaliable on a current device.
Is it better to use then standart Unity Player Prefs? - It's a bit diffrent, both sytems serve the same purpose. But Player Prefs is like a big Dictionary file. And all of your records are stored in the smae file. With IOS Native local cache API each key is a different file which means Player Prefs suits better for saving small Key / Value records. But if you save big data files or images locally, you should do that with this API.
You can save simple strings (feets greate for big JSON files data), byte (feets for any file type) and textures. The code snippet below will demostrage how to save those data type to a local app storage
SA.IOSNative.Storage.AppCache.Save ("TEST_KEY", "Some String"); Texture2D image = GetTexture(); SA.IOSNative.Storage.AppCache.Save ("TEST_IMAGE_KEY", image); byte data = GetData(); SA.IOSNative.Storage.AppCache.Save ("TEST_DATA_KEY", data);
You can easily load any data you've saved earlier. See the code snippet below:
string val = SA.IOSNative.Storage.AppCache.GetString ("TEST_KEY"); Texture2D cachedImage = SA.IOSNative.Storage.AppCache.GetTexture ("TEST_IMAGE_KEY"); byte cachedData = SA.IOSNative.Storage.AppCache.GetData ("TEST_DATA_KEY");
Remove a key with data