数据库无法在手机内存中工作,但可以在 Blackberry 中使用 SDCard 正常工作
我正在构建一个 Blackberry 应用程序,在应用程序启动时我将在其中创建一个数据库。问题是代码在 sdCard 上运行良好,但是当我删除 SDCard 并尝试使用 Phone Memory 时,它不起作用。 这是我用来创建数据库的代码:
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();
}
}
请建议
I am building an Blackberry application in which I am creating a database as the application launches . The problem is that the code works fine with sdCard but but when i am removing the SDCard and trying to use Phone Memory , its not working.
Here is the code I am using to create the database:
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();
}
}
Please suggest
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅在某些型号上,BlackBerry 支持将 SQLite 数据库保存在 eMMC 内存 (/store) 中。
例如,BlackBerry Curve 8520(您似乎拥有)不支持将 SQLite 数据库保存在 /store 中(仅在 /SDCard 中)。
BlackBerry supports saving SQLite databases in eMMC memory (/store) only on certain models.
For example, BlackBerry Curve 8520 (which you seem to have) does not support saving SQLite database in /store (only in /SDCard).