BBdev
BBdev

Reputation: 4942

Creating Database in Blackberry phone

please help me out from this I have created a database in Blackberry phone i have also created a table inside the database but on clicking on the database on blackberry simulator it shows UNABLE TO DISPLAY file ,and the code I have written is

class CreateDatabaseSchemaScreen extends MainScreen{ 
    Database d;
    public CreateDatabaseSchemaScreen(){            


         try
         {
             URI myURI = URI.create("file:///SDCard/Databases/SQLite_Guide/"    +                    "MyEncryptedDatabase.db");
              DatabaseSecurityOptions dbso = new DatabaseSecurityOptions(true);
              d = DatabaseFactory.create(myURI,dbso);
              d= DatabaseFactory.open(myURI);
              Statement s= d.createStatement("CREATE TABLE 'People' ( " +
                             "'Name' TEXT, " +
                             "'Age' INTEGER )" );
              s.prepare();
              s.execute();
              s.close();                    

              d.close();
          }
          catch ( Exception e )
          {
              System.out.println( e.getMessage() );
               e.printStackTrace();
          }
       } 
     }

Upvotes: 3

Views: 1496

Answers (1)

Marc Paradise
Marc Paradise

Reputation: 1939

Database files can't be opened directly, you'll need a third party desktop tool that allows management of it. You can find a list of these tools here (generally they're free): http://www.sqlite.org/cvstrac/wiki?p=ManagementTools

In your BB simulator settings, you will see an option that specifies where the SDCard data is located. Once you choose a management tool, open the database in that location, and you'll be able to see if the table has been created successfully.

Upvotes: 1

Related Questions