开发者

sqlite works on simulators but not on device

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,Str开发者_StackOverflow社区ing 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.


SQLLite only works on blackberries versión 5 and up. What phone's model are you using? it may be your problem. Also could you post the error your phone throws?

I also could be related to code signing. SQLite requires you to code sign your application It is not required for the simulator but it is for your phone. It's because of the API it uses to operate. Code Sign

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜