I am building an Blackberry application in which I am creating a database as the application launches . The problem is that the code works fine with sdCard but but when i am removing the SDCard and trying to use Phone Memory , its not working. Here is the code I am using to create the database:
public static String db_location="file:///SDCard/Databases/MyApp/MyDatabase.db";
public MyDatabase() {
// TODO Auto-generated constructor stub
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)
{
// If an SDCard is not available we will store our database in
// flash memory. This is not recommended for large databases.
db_location = "file:///store/home/user/Databases/MyApp/MyDatabase.db";
}
try
{
URI myURI = URI.create(db_location);
d = DatabaseFactory.create(myURI);
d.close();
}
catch ( Exception e1 )
{
System.out.println( e1.getMessage() );
e1.printStackTrace();
}
}
Please suggest
BlackBerry supports saving SQLite databases in eMMC memory (/store) only on certain models.
For example, BlackBerry Curve 8520 (which you seem to have) does not support saving SQLite database in /store (only in /SDCard).