2012-07-21 202 views
0
  1. 列表项如何在黑莓手机

    我开发的应用程序,在使用精简版平方米数据库中创建数据库。这在模拟器上正常运行。但是当我们将应用程序部署在黑莓Curve 8520手机上时。告诉我们数据库不存在。任何人都知道答案,请快速反应...

我的代码 - >

public static void insertData(String pass , String cpass) 
{ 
    boolean fl=false; 
    String root = null; 
    MainScreen ms = new MainScreen(); 
    Enumeration e = FileSystemRegistry.listRoots(); 
    while (e.hasMoreElements()) 
    { 
     root = (String)e.nextElement(); 
     if(root.equalsIgnoreCase("store/")) 
     { 
      fl=true; 
     } 
    } 
    if(!fl) 
    { 
     UiApplication.getUiApplication().invokeLater(new Runnable() 
     { 
      public void run() 
      { 
       Dialog.alert("This application requires an SD card to be present." + 
          "Exiting application..."); 
       System.exit(0); 
      } 
     }); 
    } 
    else 
    { 
     String dbLocation = "C:/om12345/sql/res/store/"; 
     // Create URI 
     // Statement st=null; 
     try 
     { 
      URI myURI = URI.create("file:///store/home/user/databases/database.sqlite"); 
      //URI myURI1=URI. 
      d = DatabaseFactory.create(myURI); 
      Statement st = d.createStatement("insert into Admin (pass, Cpass) values('"+ pass+"','"+cpass+"')"); 
      st.prepare(); 
      st.execute(); 
      st.close(); 
      d.close(); 
      //ms.add(new RichTextField ("tata" + "tata1")); 
      // UiApplication.getApplication.invokeLater(pushScreeen(ms)); 
     } 
     catch (Exception e1) 
     { 
      System.out.println(e1.getMessage()); 
      e1.printStackTrace(); 
     } 
    } 

回答

0

首先你需要改变这一行: “字符串dbLocation =” C:/ om12345/SQL/RES /商店/ “;”因为这是指开发计算机上的某个位置,但不适用于移动设备。你需要指向应用程序本身的'res'文件夹。

+1

的代码可以使用一些清洗一看。 dbLocation字符串没有被传递给DatabaseFactory.create(),所以建议不会有帮助。请给出 – 2012-07-21 19:42:30

+0

,你给出适当的答案这个问题。作为数据库路径 – 2012-08-03 16:56:07

+0

我想说,你可以告诉我一步一步解决这个问题。请问..... – 2012-08-05 14:53:52

1

对于8520,您可能无法在/store上存储sqlite数据库。有关该更多信息,请参阅我的回答BlackBerry SQLite database creation: "filesystem not ready"

+0

但你知道,这是商店的数据。所以,我怎么接受这个想法。 – 2012-08-03 16:54:43

+0

我不明白你的意见 – 2012-08-03 18:55:03

0

如果您的内部存储少于1GB,那么您不能在存储目录中创建数据库&您已将数据库保存在C目录中,该目录可以从系统访问,但不能在设备上访问。所以将其位置复制到res文件夹中。 &检查您是否有SD卡,然后使用/ SDCard保存您的数据库。 如果SD卡不可比你将能够访问数据库,如果你有超过1GB的内部存储 更多有此链接

http://docs.blackberry.com/en/developers/deliverables/17952/SQLite_database_files_1219778_11.jsp 
相关问题