我在尝试访问NullpointerException
文件夹中的db
时收到Assets
。 db
文件夹中Assets
的颜色显示为红色。
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();
}
有没有办法检查String中的db值?
答案 0 :(得分:0)
DB_NAME与资产文件夹中文件的名称不匹配。
你没有说出价值的任何理由?