Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5274] Android: copy folder with contents

GitHub Issuen/a
TypeNew Feature
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2011-09-12T13:23:55.000+0000
Affected Version/sRelease 1.7.3
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterJon Alter
AssigneeMarshall Culpepper
Created2011-09-12T12:40:15.000+0000
Updated2017-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();

Associated Helpdesk Ticket

http://appc.me/c/APP-728922

Comments

  1. Jon Alter 2011-09-12

    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.
  2. Lee Morris 2017-03-09

    Closing ticket as invalid.

JSON Source