私の資産フォルダに.zipファイルがあります。このファイルは、デバイス上のフォルダの.zipに1-1をコピーしたいものです。/assetsからsdcardにジップをコピーする
作品の種類ですが、出力ジップにもわからないものが含まれています。
私が持っているもの:
入力:
資産: Map.mp3
出力:
Map.zip
の資産+ META-INF + ORG + RES +のAndroidManifest.xml + classes.dex + resources.arsc(すべてのAPKファイル)
Map.zip/assetsに有するMap.mp3があるのに対し初期の内容しかし、私はちょうどファイルの拡張子を変更して1-1のコピーを持っている必要があります。
マイコード:
//taken from: http://stackoverflow.com/questions/4447477/android-how-to-copy-files-from-assets-folder-to-sdcard
AssetManager assetManager = getAssets();
AssetFileDescriptor assetFileDescriptor = null;
try
{
assetFileDescriptor = assetManager.openFd("Map.mp3");
// Create new file to copy into.
File output= new File(_FILEPATH_ + java.io.File.separator + "Map.zip");
output.createNewFile();
copyFdToFile(assetFileDescriptor.getFileDescriptor(), output);
}
catch (IOException e)
{
e.printStackTrace();
}
public static void copyFdToFile(FileDescriptor src, File dst) throws IOException {
FileChannel inChannel = new FileInputStream(src).getChannel();
FileChannel outChannel = new FileOutputStream(dst).getChannel();
try {
inChannel.transferTo(0, inChannel.size(), outChannel);
} finally {
if (inChannel != null)
inChannel.close();
if (outChannel != null)
outChannel.close();
}
}
_FILEPATH_
= Environment.getExternalStorageDirectory()getAbsolutePath()+ "/ osmdroid"