Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23470] Android: Saving photos to external directory still causing app data size to grow

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionDuplicate
Resolution Date2016-06-06T20:56:29.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
LabelsAndroid, data, photo, size
ReporterJeremy S
AssigneeHieu Pham
Created2016-06-01T20:33:04.000+0000
Updated2017-03-22T21:59:42.000+0000

Description

Taking photos and saving them outside of the applicationdatadirectoy is causing the data size of the app to grow even though no data is being saved to the app. To reproduce, use the following code in app.js:
var window = Titanium.UI.createWindow({
	backgroundColor : 'white'
});

var _storage = Ti.Filesystem.applicationDataDirectory;
if (Ti.Filesystem.isExternalStoragePresent()) {
	_storage = 'file:///sdcard/';
};

var folder = Ti.Filesystem.getFile(_storage, 'images/');
if (!folder.exists()) {
	folder.createDirectory();
	var saveLocation = 'images/';
};

var takePhoto = Titanium.UI.createButton({
	title : 'Open Camera',
});

takePhoto.addEventListener('click', function(e) {
	var timeInMs = Date.now();
	Titanium.Media.showCamera({
		showControls : true,
		autorotate : false,
		saveToPhotoGallery : false,
		success : function(event) {
			var image = event.media;
			var file = Ti.Filesystem.getFile('file:///sdcard/images/', timeInMs + '.jpg');
			file.write(image);
		},
	});

});

window.add(takePhoto);
window.open({
	fullscreen : true
});
Run the app and take not if the initial data size on the device. Repeatedly take photos and verify they are saved outside of the applicationdatadirectory in a folder called 'images' As photos are taken and saved, the data size of the app will continue to grow, even though the images are not in the app.

Comments

  1. Nazmus Salahin 2016-06-02

    Hello, I am able to reproduce this issue with given code and given steps. *Steps:* 1. Create a default classic project for android with given code. 2. Build and run the app on Android Device. 3. Take note of initial size of the app from settings. [Screenshot| https://i.imgsafe.org/ff91a5e91d.png] 4. Take some photos from the app by clicking OPEN CAMERA. 5. Take note of the app size again. It is apparent that the app size is increased. [Screenshot| https://i.imgsafe.org/ff950169ce.png] Thanks *Environment*: *Device info:* HTC One (android 4.4.3) *Node.js Version:* 0.12.7 *npm Version:* 2.11.3 *Titanium SDKs:* 5.4.0.v20160509133737 *Java Development Kit Version:* 1.8.0_73 *Titanium CLI Version:* 5.0.5 *Appcelerator CLI Version:* 5.2.2 *Appcelerator Studio:* 4.5.0
  2. Ashraf Abu 2016-06-03

    [~nsalahin] What happens when you press, Clear Data and Clear Cache? And can you try this on Android 6.0 as well?
  3. Hieu Pham 2016-06-06

  4. Lee Morris 2017-03-22

    Closing ticket as duplicate and links to the related ticket has been provided above.

JSON Source