开发者

filesystem error(12)

i got a file system error(12) in in blackberry application when creating 开发者_开发百科a sqlite database. can plz help me what is that error


to create a database using sqlite you need URI object,and path

you need to create a SDCard using the simulator

dbName="NameOfDB.db"; path="file:///SDCard/Databases/"+dbName; uri = URI.create(path);

Hope this will solve your problem


My colleague just wrote this great post about Using SQLite in Blackberry Applications. It touches upon file system error 12, as well as in which situations you cannot use SQLite on a blackberry.


If you run the app using a simulator first crate a folder (say) SDCard and then create a subfolder Databases. And when run the app,tke the menu 'simulate'> Change SDCard,click on 'Add Directory'Then browse fothe folder SDcard and select it and then run the app.

If you are debeg using a phone,After debeging ,you must disconnect the code from the phone and then run. You can also check whether the database is created on the phone using 'mass mode'(when connected to a system using code).


Solution file system error 12:

To open a database, you can use theopenmethod or theopenOrCreatemethod, both in the DatabaseFactory class.

You can open multiple read-only connections to a database, but only one read-write connection can be made at the same time.

If you want to open a database as both read-write and read-only, open it as read-write first. An attempt to open a database as read-write when it is already open (either as read-write or read-only) will generate "File system error 12", which indicates that there was an attempt to open more than one read-write connection to the same database.

To close a database, use the close method. To ensure that close is always called, you should call it in a finally block.

Database _db = null;
public static final String DBName = "file:///SDCard/Mobion/mobion_music.db";

URI uri = URI.create(DBName);
if (!DatabaseFactory.exists(uri))
{
  createDB(uri);// create database DBName
}
else
{
  _db = DatabaseFactory.open(uri, true);
  _db.close();
  _db = DatabaseFactory.open(uri);
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜