Exemple de code : création d'une base de données SQLite cryptée
/* CreateEncryptedDatabase.java
*
* Research In Motion Limited proprietary and confidential
* Copyright Research In Motion Limited, 2010
*/
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.database.*;
import net.rim.device.api.io.*;
public class CreateEncryptedDatabase extends UiApplication
{
public static void main(String[] args)
{
CreateEncryptedDatabase theApp = new CreateEncryptedDatabase();
theApp.enterEventDispatcher();
}
public CreateEncryptedDatabase()
{
pushScreen(new CreateEncryptedDatabaseScreen());
}
}
class CreateEncryptedDatabaseScreen extends MainScreen
{
Database d;
public CreateEncryptedDatabaseScreen()
{
LabelField title = new LabelField("SQLite Create Encrypted Database Sample",
LabelField.ELLIPSIS |
LabelField.USE_ALL_WIDTH);
setTitle(title);
add(new RichTextField("Creating an encrypted database called " +
"MyEncryptedDatabase.db on the SDCard."));
try
{
URI myURI = URI.create("file:///SDCard/Databases/SQLite_Guide/" +
"MyEncryptedDatabase.db");
DatabaseSecurityOptions dbso = new DatabaseSecurityOptions(true);
d = DatabaseFactory.create(myURI,dbso);
d.close();
}
catch ( Exception e )
{
System.out.println( e.getMessage() );
e.printStackTrace();
}
}
}
Sujet parent : Exemples de code
Ces informations vous ont-elles été utiles ? Envoyez-nous vos commentaires.