我在获取NullpointerException
时尝试访问Assets
文件夹中的db
。在Assets
文件夹中,db
显示为红色。在资产文件夹中打开sqlite数据库时出错
public void createdatabase() throws IOException
{
System.out.println(" came into Create database ");
//Open your local db as the input stream
InputStream myinput = mycontext.getAssets().open(DB_NAME);
System.out.println(" myinput = "+myinput.toString());
System.out.println(" Got input ");
// Path to the just created empty db
String outfilename = DB_PATH + DB_NAME;
System.out.println(" outfilename = "+outfilename);
//Open the empty db as the output stream
OutputStream myoutput = new FileOutputStream(outfilename);
// transfer byte to inputfile to outputfile
System.out.println(" created outputStream");
byte[] buffer = new byte[1024];
int length;
while ((length = myinput.read(buffer))>0) {
myoutput.write(buffer,0,length);
}
//Close the streams
myoutput.flush();
myoutput.close();
myinput.close();
}
有没有什么办法来检查字符串的分贝值?
发布您的代码从资产 –
越来越分贝但代码停在myinput显示NullPointerException异常 –
的你得到的是不要让分贝 –