File outfile = new File("/data/data/com.paad.citys/databases/default.db");
File outfile =
new
File(
"/data/data/com.paad.citys/databases/default.db"
);
02.
03.
if
(outfile.length() >
0
)
return
;
04.
05.
AssetManager assetManager = getResources().getAssets();
06.
try
{
07.
InputStream is = assetManager.open(
"database/default.db"
, assetManager.ACCESS_BUFFER);
08.
AssetFileDescriptor af = assetManager.openFd(
// FileNotFoundException 발생
09.
long
filesize = af.getLength();
10.
byte
[] tempdata =
[(
int
)filesize];
11.
is.read(tempdata);
12.
is.close();
13.
14.
outfile.createNewFile();
15.
FileOutputStream fo =
FileOutputStream(outfile);
16.
fo.write(tempdata);
17.
fo.close();
18.
}
catch
(IOException e) {
19.
// TODO Auto-generated catch block
20.
e.printStackTrace();
21.
로그인 유지
간단하게 테스트 하는 방법은
asset폴더에 임시 test html을 작성하셔신 후
drawable에 저장된 이미지를 가져다가 세팅해 보시는게 좋을 거 같네요
아래 소스를 참조하세요
File outfile =
new
File(
"/data/data/com.paad.citys/databases/default.db"
);
02.
03.
if
(outfile.length() >
0
)
return
;
04.
05.
AssetManager assetManager = getResources().getAssets();
06.
try
{
07.
InputStream is = assetManager.open(
"database/default.db"
, assetManager.ACCESS_BUFFER);
08.
AssetFileDescriptor af = assetManager.openFd(
"database/default.db"
);
// FileNotFoundException 발생
09.
long
filesize = af.getLength();
10.
byte
[] tempdata =
new
byte
[(
int
)filesize];
11.
is.read(tempdata);
12.
is.close();
13.
14.
outfile.createNewFile();
15.
FileOutputStream fo =
new
FileOutputStream(outfile);
16.
fo.write(tempdata);
17.
fo.close();
18.
}
catch
(IOException e) {
19.
// TODO Auto-generated catch block
20.
e.printStackTrace();
21.
}