android - Join file in APK to store them in SD card -
for reason need join defaut file apk need write sd card because app try read sd card need store first time default file in sd card
how can't paste data in root folder android refuse if paste on drawable folder seems ok compiling still duno how content , write on sd card
i have see many tuto tu drawable sd card wan't opposite write file on sd card default file have join apk
any idea? don't have code because don't have tips that
zip file(s) , put zip file (name my_raw_files.zip
) folder res/raw
in eclipse , packaged app. can copy @ first start of app external storage ("sdcard"):
private static final file user_dir = new file(environment.getexternalstoragedirectory().getabsolutepath() + file.separator + "myfolder"); ... boolean dircreated = user_dir.mkdirs(); if (dircreated) { filesutil.unzipfiles(this.getresources().openrawresource(r.raw.my_raw_files), user_dir.getabsolutepath()); } ... static public void unzipfiles(inputstream zipis, string outputpath) { try { // unzip files existing folder structure zipinputstream zin = new zipinputstream(zipis); try { zipentry ze; while ((ze = zin.getnextentry()) != null) { if (!ze.isdirectory()) { log.d(tag, "unzip " + ze.getname()); bytearrayoutputstream baos = new bytearrayoutputstream(); byte[] buffer = new byte[1024]; int count; fileoutputstream fout = new fileoutputstream(outputpath + file.separator + ze.getname()); while ((count = zin.read(buffer)) != -1) { baos.write(buffer, 0, count); byte[] bytes = baos.tobytearray(); fout.write(bytes); baos.reset(); } fout.close(); } } } { zin.close(); } } catch (exception e) { log.e(tag, "unzip", e); } }
Comments
Post a Comment