我在獲取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異常 –
的你得到的是不要讓分貝 –