如果您使用与“PersistentStoreDemo”相同的存储区,如果您不知道可以通过进入File->Import->Blackberry Samples获得该存储区,则可以加密存储区中的信息。除此之外,如果用户启用了内容保护,则可以使用ContentProtectedHashtable自动知道该信息将被加密。因此,如果没有内容保护,信息将被加密一次,打开它,它将被双重加密,并与应用程序名称空间的难以猜测的长散列一起存储(显然,因为注册存储需要它)。下面是我使用的:
package ca.dftr.phillyd.lib.persistables;
import net.rim.device.api.system.ApplicationDescriptor;
import net.rim.device.api.util.ContentProtectedHashtable;
import net.rim.device.api.util.Persistable;
/**
* Basic class for storing application specific information.
* Information such as application settings or whether the license agreement was accepted.
* For more complex and specific classes they should be implemented separately and implement persistable
* @author deforbes
*/
public class AppInfo extends ContentProtectedHashtable implements Persistable {
private String _appName = null;
private String _version = null;
/**
* Constructs the application info, creates and persists a hashtable for application settings.
* @param uniqueHexAppIdentifier Can be automatically created in resource class (BUNDLE_ID) or generated using other unique information.
*/
public AppInfo() {
ApplicationDescriptor appDesc = ApplicationDescriptor.currentApplicationDescriptor();
_appName = appDesc.getName();
_version = appDesc.getVersion();
}
/**
* Get the Name of the application
* @return The application name from the app descriptor
*/
public String getName()
{
return _appName;
}
/**
* Get the Version of the application
* @return The application version from the app descriptor
*/
public String getVersion()
{
return _version;
}
}
以及一类常量(如果需要,可以包含在上面的内容中)。例如,从我的PhillyD应用程序:
包裹约dftr.phillyd.库持久性;
/**
* Keys for the AppInfo array
* @author deforbes
*/
public class AppInfoKeys {
public static final String QUALITY = "Quality";
public static final String CHANNEL = "Channel";
public static final String CHANNEL_NAME = "Channel_Name";
public static final String SEARCH = "Search";
public static final String LICENSE_ACCEPTED = "isLicenseAccepted";
public static final String VIDEOS_PER_PAGE = "NumPerPage";
public static final Boolean DOWNLOAD_THUMBS = new Boolean(true);
}