Changes

Jump to: navigation, search

Teams Winter 2011/team1/BlackBerry/Use SQLite

1,236 bytes added, 21:53, 11 April 2011
11.4 Check for presence of SDCard
===11.4 Check for presence of SDCard===
Each time our "Student View" application runs, we have to check for the presence of the SD card, and if it does not exist, we have to show a dialog message.
 
Therefore, add the following code to the ViewStudentApp.java class constructor:
<source lang="java">
 
public ViewStudentApp() throws Exception {
//This part is from BB Sample application
// 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
{
// the rest of code goes here
 
}
</source>
===11.5 Copy Database File into SDCard===
1
edit

Navigation menu