如果您使用的商店與「PersistentStoreDemo」相同,如果您不知道可以通過轉到文件 - >導入 - >黑莓示例獲取該商店,則可以加密商店中的信息。最重要的是,如果用戶擁有內容保護,則可以使用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應用程序:
package ca.dftr.phillyd.lib.persistables;
/**
* 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);
}
PersistableRIMKeyStore用於保存RIM密鑰庫。要跨越重置持續保存用戶數據,只需使用PersistentStore,如果您想要保護deta,則可以使用ContentProtectedHashtable或ContentProtectedVector – Richard 2010-08-25 18:01:52
Richard,非常感謝您的快速響應!我會研究你的建議。 – 2010-08-25 19:22:33
@Richard:你可以發表你的評論作爲答案 - 我將接受它作爲解決方案。 – 2011-08-21 17:32:24