Öğelerim klasöründe, aygıtımdaki bir klasörde .zip dosyasına kopyalamak istediğim bir .zip dosyası var.Bir zip öğesini/varlıkları sdcard dosyasına kopyalama
Bu tür işler, ancak çıktı zip de anlamadığım şeyler içeriyor.
Ben Ne:
Girdi:
varlıkları: Map.mp3
Çıktı:
Map.zip
Map.zip/assets içindevarlıklar + META-INF + org + res + AndroidManifest.xml'sinde + classes.dex + resources.arsc (bütün APK dosyası)
Oysa bir Map.mp3 var ilk içerik. Ama sadece dosya uzantısı değiştiğinde 1-1 kopyaya ihtiyacım var.
Kodum:.
//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" Her zaman basit dosya kopyalama prosedürünü kullanabilirsiniz