안녕하세요..
db 배포시에 asset폴더에 있는 데이터 베이스를 지정된 경로로 복사하려고 합니다.
밑의 소스처럼 구현하려고 하는데요. 에뮬레이터 실행은되는데 복사가 이루어지지 않습니다..
많은 도움 부탁드립니다..
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import android.app.Activity;
import android.content.res.AssetManager;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
public class update extends Activity implements OnTouchListener {
/** Called when the activity is first created. */
public void copydb(Activity act) {
AssetManager am = act.getAssets();
File f = new File("/data/data/material.data.db/databases/Material.db");
FileOutputStream fos = null;
BufferedOutputStream bos = null;
try {
InputStream is = am.open("Material.db");
BufferedInputStream bis = new BufferedInputStream(is);
// 만약에 파일이 있다면 지우고 다시 생성
if (f.exists()) {
f.delete();
f.createNewFile();
}
fos = new FileOutputStream(f);
bos = new BufferedOutputStream(fos);
int read = -1;
byte[] buffer = new byte[1024];
while ((read = bis.read(buffer, 0, 1024)) != -1) {
bos.write(buffer, 0, read);
}
bos.flush();
fos.close();
bos.close();
is.close();
bis.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public boolean onTouch(View arg0, MotionEvent arg1) {
// TODO Auto-generated method stub
return false;
}
}




디비 용량이 어떻게 되나요...900 이상은 안될껀데..
그리고 배포시 디비를...한번 생성하고 하고 싶으시다면..
그냥 디비파일 포맷을 mp3로 바꾸시면 용량 관계 없이 들어갑니다^^
구글링 해보시면 소스까지 다 있어용~