У меня есть .zip-файл в папке моих ресурсов, который я хочу скопировать 1-1 в .zip в папку на моем устройстве.Копирование zip из/активов в SDCard
Это вид работ, но выход zip содержит также материал, который я не понимаю.
Что у меня есть:
ввода:
активы: Map.mp3
Выход:
Map.zip
активы + META-INF + орг + Рез + 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"