0
我正在开发以数据库作为后端的黑莓手机应用程序。数据库有一些数据,所以我将数据库从res导入到sdcard
,它在模拟器中正常工作。 当我安装my app into device
那么它不工作可能是我无法理解的问题。下面是我的代码..如何将数据库复制到黑莓手机中的设备
调用方法
DatabseCopy db=new DatabseCopy();
db.copyFile("/nm.db","file:///SDCard/Databases/nm.db");
方法
public void copyFile(String srFile, String dtFile)
{
try
{
FileConnection fconn;
fconn = (FileConnection) Connector.open(dtFile,Connector.READ_WRITE);
if(!fconn.exists()) // if file does not exists , create a new one
{
fconn.create();
}
InputStream is = (InputStream)this.getClass().getResourceAsStream(srFile);
OutputStream os =fconn.openOutputStream();
byte[] buf = new byte[1024];
int len;
while ((len = is.read(buf)) > 0)
{
os.write(buf, 0, len);
}
is.close();
os.close();
}
catch(IOException e)
{
System.out.println("Exception"+e.getMessage()) ;
}
}
你得到了哪个错误?如果你想更多来这里http://chat.stackoverflow.com/rooms/4014/knowledge-sharing-center-for-blackberry-and-java – 2011-12-16 07:51:22
更好地改变标题 – alishaik786 2011-12-16 12:14:15