开发者

Changing permissions on a File from applicationDataDirectory in Titanium Mobile

I'm trying to send a file, as an attachment, via the phone's e-mail client using Titanium Mobile. I've run into a snag where the attachment is sent, but is received as a 0-byte file.

The problem is that the file created in data/data/package/app_appdata is -rw------

From glancing at the Android SDK, this is by design. The app's "private storage" is readable only by the owner of that folder, the running application. I presume that the Android e-mail client can see that file, but cannot read it.

The full Android SDK mentions a MODE_WORLD_WRITABLE that allows you to keep using the applicationDataDirectory and give all apps permission to read/write that file. Does an equivalent exist in Titanium Mobile?

The other solution is to create a temp file, which unfortunately uses Titanium's own naming scheme (tiXXXXX.txt), or I could write to the "external stora开发者_运维知识库ge" since it is public (which may not always be available, however.)

This is the call I'm using to get the current file, it can be read within my app just fine, but when I use the addAttachment call of an emailDialog it simply sends a 0 byte file to me.

var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "generated_filename.txt")


Have you tried using tempDirectory instead. I'm of course assuming once the file is emailed you don't need to keep it as the applicationDataDirectory is fully backed up and usually used to store data the app retains.

http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Filesystem.tempDirectory-property.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜