基于 sqlite 数据库中的数据在 Blackberry UI 应用程序上推送屏幕时出现问题
我试图根据数据库是否创建以及是否创建来将屏幕推到主 UiApplication (MyApp) 上,如果创建了,那么它是 emapty 还是有一些数据。 但是当我运行此代码时,我的 balckberry 应用程序 jsts 挂起..
感谢任何帮助:)
我已经检查了虚拟 SDCard 是否存在于模拟器中,我什至有代码在运行时检查 SDCard 是否可用。
JDE 版本 6.0,带 Eclipse Helios
插入 BlackBerry Simulator:9800
操作系统:windows 7 32 位终极版< /p>
下面是我在应用程序中使用的代码
public MyApp()
{
try {
MyAppURI = URI.create("file:///SDCard/BlackBerry/Database/"
+ "MyApp.db");
this.setMyURI(MyAppURI);
boolean flag = false;
flag = DatabaseFactory.exists(getMyURI());
if ( flag == false){
db = DatabaseFactory.create(getMyURI());
db.close();
new DatabaseSchema(); // this will simpaly create setting table in databse MyApp.db i am closing the database there
pushScreen(new Settings());
}else{
db = DatabaseFactory.open(getMyURI());
Statement st = db.createStatement("select count(*) from Setting");
Cursor cursor = st.getCursor();
if (cursor.isEmpty() == true){
pushScreen(new Settings());
}else{
pushScreen(new Reports());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
I am trying to push the screen on may main UiApplication (MyApp) based on the either database is created or not and if its created than is it emapty or is it having some data..
but when i run this code my balckberry application jsts hangs ..
any help is appreciated :)
i have checked that the virtual SDCard is there in simulator and i have even code to check at runtime whether SDCard is avialable or not.
JDE Version 6.0 with Eclipse Helios
plug in BlackBerry Simulator : 9800
Os : windows 7 32 bit ultimate edition
below is my code that i am using in my app
public MyApp()
{
try {
MyAppURI = URI.create("file:///SDCard/BlackBerry/Database/"
+ "MyApp.db");
this.setMyURI(MyAppURI);
boolean flag = false;
flag = DatabaseFactory.exists(getMyURI());
if ( flag == false){
db = DatabaseFactory.create(getMyURI());
db.close();
new DatabaseSchema(); // this will simpaly create setting table in databse MyApp.db i am closing the database there
pushScreen(new Settings());
}else{
db = DatabaseFactory.open(getMyURI());
Statement st = db.createStatement("select count(*) from Setting");
Cursor cursor = st.getCursor();
if (cursor.isEmpty() == true){
pushScreen(new Settings());
}else{
pushScreen(new Reports());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
理想情况下,您应该在自己的线程中运行这些数据库操作,因为它们是阻塞操作。我发现有用的一件事是,当我从构造函数推送它们时,如果它们没有显示,请将它们放入
invokeLater()
调用中适当地。这允许系统在显示屏幕之前完成任何需要完成的事情,然后就可以进行推送。Ideally you should be running these database operations in their own Thread, as they are blocking operations. One thing that I've found helpful is to put my
pushScreen()
s ininvokeLater()
calls when I'm pushing them from a constructor if they aren't displaying properly. This allows the system to finish anything that needs to be done prior to displaying aScreen
, and then it will be able to push.