Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later
Accepted Solution

SQLLite demo

http://www.blackberry.com/go/sqlitedemo

 

 

Have downloaded this, when i run my simulator...i choose simulator  --> memory and i tick use pc file system for sd card files , i build a folder SDCard on desktop.

 

So all goes fine, it sees the desktop.

but at  CodeSigningKey codeSigningKey = CodeSigningKey.get(CodeModuleManager.getModuleHandle( "SQLiteDemo" ), "XYZ"); it gives the error,  uncaught exception java.lang.illegalArgumentException

 

any helps?

Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: SQLLite demo

 public SQLiteDemo() throws Exception
    {       
        // Determine if an SDCard is present 
        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)
        {
            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 = "/SDCard/databases/SQLite Demo/"; 
            
            // Create URI            
            URI uri = URI.create(dbLocation + DB_NAME);     
            
            // Open or create a plain text database.  This will create the
            // directory and file defined by the URI (if they do not already exist).
            Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));  
            
            // Close the database in case it is blank and we need to write to the file
            db.close();
            
            // Open a connection to the database file        
            FileConnection fileConnection = (FileConnection)Connector.open("file://" + dbLocation + DB_NAME);    
            
            // If the file is blank, copy the pre-defined database from this
            // module to the SDCard.
            if(fileConnection.exists() && fileConnection.fileSize() == 0)
            {                      
                readAndWriteDatabaseFile(fileConnection);           
            }         
            
            // Retrieve the code signing key for the XYZ key file
            CodeSigningKey codeSigningKey = CodeSigningKey.get(CodeModuleManager.getModuleHandle( "SQLiteDemo" ), "XYZ");
            
            try
            {
                // Encrypt and protect the database.  If the database is already
                // encrypted, the method will exit gracefully. 
                DatabaseFactory.encrypt(uri, new DatabaseSecurityOptions(codeSigningKey));
            }
            catch(DatabaseException dbe)
            {
                errorDialog("Encryption failed - " + dbe.toString());         
            }
            
            // Open the database            
            db = DatabaseFactory.open(uri);
            
            // Create a new main screen and push it onto the display stack        
            SQLiteDemoScreen screen = new SQLiteDemoScreen(new SQLManager(db));        
            pushScreen(screen);                          
        }
    }
        

 

Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: SQLLite demo

if i comment this part, everything works perfect

// Retrieve the code signing key for the XYZ key file
CodeSigningKey codeSigningKey = CodeSigningKey.get(CodeModuleManager.getModuleHandle( "SQLiteDemo" ), "XYZ");

try
{
// Encrypt and protect the database. If the database is already
// encrypted, the method will exit gracefully.
DatabaseFactory.encrypt(uri, new DatabaseSecurityOptions(codeSigningKey));
}
catch(DatabaseException dbe)
{
errorDialog("Encryption failed - " + dbe.toString());
}


btw, i do have file XYZ.key
Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: SQLLite demo

here isone thing happening, i click on the project..then blackberry, then singature with tool..

it gives me xyz.key not registered. hwo can i fix this? i am using blackberry jre 7.0.0.
Developer
Posts: 174
Registered: ‎01-25-2011
My Device: Not Specified

Re: SQLLite demo

[ Edited ]

You need  to install blackberry signing authority tool to create ur own .key file and signatures for that.... 

 

And as far as ur error message is concern, IllegalArgument is displayed when ur module name(.cod name) is doesnot match with the name given in the method!!!

 

Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: SQLLite demo

I have done so, and it worked.Downlaoded authority tool...and the .key file was signed to my application.cod file. it was signed, and everything went fine