[TIMOB-5274] Android: copy folder with contents
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Low |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2011-09-12T13:23:55.000+0000 |
Affected Version/s | Release 1.7.3 |
Fix Version/s | n/a |
Components | Android |
Labels | n/a |
Reporter | Jon Alter |
Assignee | Marshall Culpepper |
Created | 2011-09-12T12:40:15.000+0000 |
Updated | 2017-03-09T23:41:21.000+0000 |
Description
In iOS you can copy a folder and all of its contents with the example below.
Android throws a null pointer exception.
Requesting the ability to copy a folder and all its contents for parity with iOS.
Step 1: create a folder named "data" in your resources directory and make some files in it.
Step 2: run the code below
Step 3: click the "Copy Folder button
Step 4: notice the null pointer exception
(This should copy the folder with contents and print the contents of the folder to the log)
var win = Ti.UI.createWindow({
backgroundColor: '#fff',
layout: 'vertical'
});
var testButton = Ti.UI.createButton({
title: "Copy Folder",
top: 20,
height: 50,
width: 250,
});
testButton.addEventListener('click', function(e){
// this will copy the data folder and its contents
var srcDataDir = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, "data");
var destDataDir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "data");
destDataDir.write(srcDataDir.read());
Ti.API.info("listing: " + destDataDir.getDirectoryListing());
});
win.add(testButton);
win.open();
This is not the correct way to copy a folder with contents. The correct way is to walk the tree and copy each file individually.
Closing ticket as invalid.