0
votes

I don't have any knowledge on working with Sqlite database on Blackberry. Recently i delved into database with Blackberry. When i tried to create the database, the database gets successfully created on Simulator(Simulate-->ChangeSDCard-->MountDirectory) on Some particular folder.

Next when i try to Open the database for creating tables & inserting data--

       String db_url ="file:///SDCard/Databases/"+"sampleTest.db";
      db = DatabaseFactory.open(db_url);  

It through the DatabaseException error with message :"Invalid path name. Path does not contains a proper root list. See FileSystemRegistry class for details."

Please help me !! What is going Wrong here.

1
it, is not getting path of sdcard... - Hasmukh
first you have to set sdcard in simulator.. - Hasmukh
@Hasmukh I have set SDCard path too, & then run the application using (Simulate-->ChangeSDCard-->MountDirectory). But it is throwing an exception. - Prem Singh Bist
how can i ensure that.. the device SDCard path is set? Thank you. - Prem Singh Bist

1 Answers

1
votes

First set Sdcard in Simulator: Go Simulate-->change sdcard-->Add directories(sdcard folder path)

Write Query like this:

public Vector GetData()
    {           
        Cursor c = null;
        Statement st = null;
        Vector tableVector=new Vector();
        try 
        {

            URI myURI = URI.create("/SDCard/" + "abc.db");
            d = DatabaseFactory.open(myURI);
            st= d.createStatement("Query"););            
            st.prepare();             
            c = st.getCursor();            
            Row r;            
            while(c.next()) 
            {               
                r = c.getRow();                 
                tableVector.addElement(r.getString(0)); 
            }           
        }
        catch ( Exception e ) 
        {      
            System.out.println( e.getMessage() );
            e.printStackTrace();
        }
        finally 
        {          

            try {
                c.close();
            } catch (DatabaseException e) {

                e.printStackTrace();
            }
            try {
                st.close();
            } catch (DatabaseException e) {

                e.printStackTrace();
            }
            try {
                d.close();
            } catch (DatabaseIOException e) {

                e.printStackTrace();
            }
        }
        return tableVector;


    }