PDA

View Full Version : درخواست یه کد



capitan_nemesis
یک شنبه 13 فروردین 1396, 18:00 عصر
با سلام به همه
من یه کدی میخوام داشتمش ولی متاسفانه پاک شد خوب چاره چیست
وقتی sqlite رو داخل assets کپی میکنی میخوای بخونیش از روی این فلدر میدونم یه کد داخل سطح کلاس کپی میکردی فقط باید پایگاه رو بخونی روش
حالا سوال اینجاست
این کد چی بود ؟؟؟
ممنون میشم کمک کنید
:خجالت::خجالت::خجالت::خجالت:: جالت:

capitan_nemesis
جمعه 18 فروردین 1396, 11:33 صبح
من هنوز منتظر فقط 6 خط کده اصلا پیداش نمیکنم

mojtabadj
سه شنبه 22 فروردین 1396, 13:18 عصر
private void copyDataBase() throws IOException{

//Open your local db as the input stream
InputStream myInput = myContext.getAssets().open(DB_NAME);

// Path to the just created empty db
String outFileName = DB_PATH + DB_NAME;

//Open the empty db as the output stream
OutputStream myOutput = new FileOutputStream(outFileName);

//transfer bytes from the inputfile to the outputfile
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();

}