My app makes some database connections (sqllite) and performs some basic database operations (insert,delete,search),I wrote some code for this,Its worked perfectly in simulator but not in phone,Can any one help overcome this ,Thanks in advance.I used follwing code to insert data,I already add the code to create database and tables. And I create Folder SDCard in my application's folder,
public void insertInTotblFavStationList(String url,String StationName,String imageUrl,String bitRate,String formats){
try {
URI uri = URI.create("file:///SDCard/Databases/myDb.db");
Statement statement =null;
Database grabDB = null;
grabDB = DatabaseFactory.open(uri);
statement = grabDB.createStatement("insert into tblFavStationList(url,StationName,StationImage,Bitrate,Formats) values (?,?,?,?,?)");
statement.prepare();
statement.bind(1, url);
statement.bind(2, StationName);
statement.bind(3, imageUrl);
statement.bind(4, bitRate);
statement.bind(5, formats);
statement.execute();
statement.close();
grabDB.close();
System.out.println("ins");
} catch (Exception e) {
System.out.println(e);
}
}
I have found that when my BB is connected to my Macbook EVEN IF USB filesharing is off the SDCard seems to be mounted. This means that any database files stored there are inaccessible and will throw "Invalid path name".
Check whether your SDCard is mounted by going to the camera app, if it is it will give you a warning that you can't save photos.
Try loading your app and then disconnecting the USB. It's a pain because it means you can't properly debug.