Blackberry 手机内存中的数据库不工作,黑莓SD卡也可以正常工作
我正在构建一个Blackberry应用程序,当应用程序启动时,我在其中创建一个数据库。问题是,该代码在SD卡上运行良好,但当我卸下SD卡并尝试使用手机内存时,它不起作用。 下面是我用来创建数据库的代码:Blackberry 手机内存中的数据库不工作,黑莓SD卡也可以正常工作,blackberry,blackberry-simulator,Blackberry,Blackberry Simulator,我正在构建一个Blackberry应用程序,当应用程序启动时,我在其中创建一个数据库。问题是,该代码在SD卡上运行良好,但当我卸下SD卡并尝试使用手机内存时,它不起作用。 下面是我用来创建数据库的代码: public static String db_location="file:///SDCard/Databases/MyApp/MyDatabase.db"; public MyDatabase() { // TODO Auto-generated construct
public static String db_location="file:///SDCard/Databases/MyApp/MyDatabase.db";
public MyDatabase() {
// TODO Auto-generated constructor stub
boolean sdCardPresent = false;
String root = null;
Enumeration e = FileSystemRegistry.listRoots();
while (e.hasMoreElements())
{
root = (String)e.nextElement();
if(root.equalsIgnoreCase("sdcard/"))
{
sdCardPresent = true;
}
}
if(!sdCardPresent)
{
// If an SDCard is not available we will store our database in
// flash memory. This is not recommended for large databases.
db_location = "file:///store/home/user/Databases/MyApp/MyDatabase.db";
}
try
{
URI myURI = URI.create(db_location);
d = DatabaseFactory.create(myURI);
d.close();
}
catch ( Exception e1 )
{
System.out.println( e1.getMessage() );
e1.printStackTrace();
}
}
请建议仅在某些型号上,BlackBerry支持将SQLite数据库保存在eMMC内存中(/store)
例如,BlackBerry Curve 8520(您似乎有)不支持在/store中保存SQLite数据库(仅在/SDCard中保存)。请参见编码中是否有任何prblm?。。。是的,我有8520条曲线