All Products
Search
Document Center

Mobile Platform as a Service:Custom storage

Last Updated:Feb 04, 2026

The default storage for APDataCenter is the /Documents/Preferences folder in the application sandbox. If your service is independent or handles a large volume of data, you can create a custom storage space.

You can use APCustomStorage to create a custom storage folder. In this folder, you can use all services provided by the unified storage, similar to APDataCenter. For example:

APCustomStorage* storage = [APCustomStorage storageInDocumentsWithName:@"Contact"];

Executing this code creates the Documents/Contact folder. This folder also contains commonPreferences for public data and userPreferences for user-specific data. Similar to APDataCenter, APCustomStorage handles user switching automatically. Your service does not need to manage this process.

API description

  • (instancetype)storageInDocumentsWithName:(NSString*)name;

    Creates a custom storage at the path /Documents/name.

  • (id)initWithPath:(NSString*)path;

    Creates a custom storage at any specified path. You do not typically need this method. Use storageInDocumentsWithName instead. Your service must retain the APCustomStorage object created with this method. An error occurs if multiple APCustomStorage objects have the same path.

  • (APBusinessPreferences*)commonPreferences;

    A global storage object for data that is not user-specific. It uses a key-value format to store and retrieve data. Unlike APDataCenter, you do not need the business parameter when you store key-value data in a custom storage space. You only need the key.

  • (APBusinessPreferences*)userPreferences;

    The storage object for the currently logged-in user. It uses a key-value format to store and retrieve data. If no user is logged in, this method returns nil. Unlike APDataCenter, you do not need the business parameter when you store key-value data in a custom storage space. You only need the key.

  • (id)daoWithPath:(NSString*)filePath userDependent:(BOOL)userDependent;

    For more information, see the method of the same name in APDataCenter.