public void setDB() {
String ROOT_DIR = "/data/data/com.example.mjfitness/databases/";
File folder = new File(ROOT_DIR);
if(folder.exists()) {
}
else {
folder.mkdirs();
//Toast.makeText(this, "폴더생성", Toast.LENGTH_LONG).show();
}
AssetManager assetManager = getResources().getAssets();
File outfile = new File(ROOT_DIR+"MJFitness.db"); //--폰에 위치할 경로
InputStream is = null;
FileOutputStream fo = null;
long filesize = 0;
try {
// --asset 폴더 및 복사할 DB 지정
is = assetManager.open("MJFitness.db", AssetManager.ACCESS_BUFFER);
filesize = is.available(); //--사이즈 검증
// 파일이 없거나 패키지 폴더에 설치된 DB파일이 포함된 DB파일 보다 크기가 같지않을 경우 DB파일을 덮어 쓴다.
if (outfile.length() <= 0) {
byte[] tempdata = new byte[(int) filesize];
is.read(tempdata);
is.close();
outfile.createNewFile();
fo = new FileOutputStream(outfile);
fo.write(tempdata);
fo.close();
}
else
{
//Toast.makeText(this, "db있음", Toast.LENGTH_LONG).show();
}
} catch (IOException e) {
Toast.makeText(this, "db이동실패", Toast.LENGTH_LONG).show();
}
}
빨간색으로 색칠한부분에서 do not hardcode use context.getfilesdir().getPath() instead 경고문뜨는데
이것때문에 디비가 안되는거 같아요 어떻게 해결하나요??