{ "id": "63684", "key": "TIMOB-3052", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "11244", "name": "Release 1.7.0", "archived": true, "released": true, "releaseDate": "2011-06-13" }, { "id": "11246", "name": "Sprint 2011-11", "archived": true, "released": true, "releaseDate": "2011-03-21" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-04-17T02:00:47.000+0000", "created": "2011-04-15T03:35:34.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "android", "feature", "release-1.7.0", "reported-1.6.0", "rplist" ], "versions": [], "issuelinks": [], "assignee": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2011-04-17T02:00:47.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "{html}

Problem

\n

On iOS, the \"write\" function on a Ti.Filesystem.File returns\ntrue or false depending on if the write was successful, or false if\nit's not possible to write to the file or blob. Android doesn't\nreturn anything.

\n

Sample Code

\n
\nvar file = Titanium.Filesystem.createTempFile();\nif (file.write('my super cool data') === true) {\n   alert('PASS: I wrote to a file! YESSS!');\n}\nelse {\n   alert('FAIL: I am sad, for I could not tell you I wrote to the file. Weep weep weep.');\n}\n
\n

Tested On

\n

Titanium SDK version: 1.6.0 (02/02/11 15:22 a02f7db...)
\nPASSES on iOS Simulator 4.2
\nFAILS on Android Simulator 2.2

\n

Related Documentation

\n

The docs already state that \"write\" returns a boolean, most\nlikely because that's what iOS does.
\n\nhttp://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Fil...

\n

Associated Helpdesk Ticket

\n

http://developer.appcelerator.com/helpdesk/view/70481

{html}", "attachment": [ { "id": "18257", "filename": "app.js", "author": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "created": "2011-04-15T03:35:34.000+0000", "size": 1406, "mimeType": "application/x-javascript" } ], "flagged": false, "summary": "Android: Ti.Filesystem.File.write should return boolean", "creator": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "environment": null, "comment": { "comments": [ { "id": "129941", "author": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "body": "{html}

Also note that this is causing a RHINO USAGE WARNING. It is\ndefinitely caused by trying to pull a value out of\nfile.write('whatever'), as demonstrated here:

\n

Rhino Usage Warning

\n
\nLocation: [1,0] app://app.js\nSource: {there isn't anything in here... it's blank in the alert}\nMessage: RHINO USAGE WARNING: Missed Context.javaToJS() conversion: Rhino runtime detected object undefined of class org.appcelerator.kroll.KrollProxy$1 where it expected String, Number, Boolean, or Scriptable instance. Please check your code for missing Context.javaToJS() call.\n
\n

Sample Code

\n

This is all you need in your app.js. Simple, huh? When the app\nlaunches, you should see the warning message.

\n
\nTi.Filesystem.createTempFile().write('chicken') === true;\n
\n

Trace Level Log

\n
\n[INFO] Deployed Playground2 ... Application should be running.\n[TRACE] I/Log ( 387): (main) [0,0] checkpoint, app created.\n[TRACE] I/TiApplication( 387): (main) [297,297] Titanium 1.6.0 (2011/02/02 15:22 02f7db...)\n[TRACE] D/TiApplication( 387): (main) [5,302] Application onCreate\n[TRACE] D/dalvikvm( 387): GC_FOR_MALLOC freed 3471 objects / 332160 bytes in 149ms\n[TRACE] E/TiPlatformHelper( 387): (main) [545,847] renaming ID\n[TRACE] I/Log ( 387): (main) [0,0] checkpoint, on root activity create, savedInstanceState: null\n[TRACE] E/TiRootActivity( 387): (main) [5,5] Instance Count: 0\n[TRACE] D/TiApplication( 387): (main) [148,153] Analytics Event: type=ti.start\n[TRACE] D/TiApplication( 387): event=ti.start\n[TRACE] D/TiApplication( 387): timestamp=2011-02-04T17:49:14.030-0600\n[TRACE] D/TiApplication( 387): mid=8a431ae8-f811-488a-9758-4d15bf980db2\n[TRACE] D/TiApplication( 387): sid=682aa288-3a3c-479f-acdf-bd115fa52b5d\n[TRACE] D/TiApplication( 387): aguid=d85d7f90-1fae-46cf-93e6-6e0a57d6b5f3\n[TRACE] D/TiApplication( 387): isJSON=true\n[TRACE] D/TiApplication( 387): payload={\"os\":\"sdk\",\"tz\":-360,\"nettype\":\"MOBILE\",\"deploytype\":\"development\",\"app_version\":\"1.0\",\"osver\":\"2.2\",\"un\":\"android-build\",\"version\":\"1.6.0\"}\n[TRACE] E/TiApplication( 387): (main) [275,428] APP PROXY: [Ti.App]\n[TRACE] E/ROOT ( 387): (main) [317,745] Leaving TiRootActivity.onCreate\n[TRACE] I/Log ( 387): (main) [0,0] checkpoint, on root activity resume. context = org.appcelerator.titanium.TiContext@44f19ab0\n[TRACE] I/TiRootActivity( 387): (Thread-9) [8,8] eval app.js\n[TRACE] D/KrollContext( 387): (kroll$1) [25,33] Running evaluated script: app://app.js\n[TRACE] W/TiAnalyticsSvc( 387): (Thread-10) [186,219] Analytics Service Started\n[TRACE] I/global ( 387): Default buffer size used in BufferedWriter constructor. It would be better to be explicit if an 8k-char buffer is required.\n[TRACE] D/dalvikvm( 387): GC_FOR_MALLOC freed 5135 objects / 356288 bytes in 312ms\n[TRACE] E/TiContext( 387): (kroll$1) [243,462] Rhino Error: app://app.js:1,0\n[TRACE] E/TiContext( 387): (kroll$1) [342,804] Message: RHINO USAGE WARNING: Missed Context.javaToJS() conversion:\n[TRACE] E/TiContext( 387): Rhino runtime detected object undefined of class org.appcelerator.kroll.KrollProxy$1 where it expected String, Number, Boolean or Scriptable instance. Please check your code for missing Context.javaToJS() call.\n[TRACE] E/TiContext( 387): (kroll$1) [2,806] Source: null\n[TRACE] I/TiAnalyticsSvc( 387): (Thread-10) [956,1762] Sending 1 analytics events.\n[TRACE] I/ActivityManager( 60): Displayed activity com.dawson.playground2/.Playground2Activity: 6075 ms (total 6075 ms)\n[TRACE] D/dalvikvm( 387): GC_FOR_MALLOC freed 5968 objects / 357208 bytes in 101ms\n[TRACE] D/dalvikvm( 387): GC_FOR_MALLOC freed 504 objects / 25168 bytes in 93ms\n[TRACE] W/TiAnalyticsSvc( 387): (Thread-10) [4018,5780] Stopping Analytics Service\n[TRACE] D/dalvikvm( 248): GC_EXPLICIT freed 218 objects / 14688 bytes in 87ms\n[TRACE] D/dalvikvm( 258): GC_EXPLICIT freed 31 objects / 1496 bytes in 91ms\n[TRACE] D/dalvikvm( 132): GC_EXPLICIT freed 200 objects / 10696 bytes in 66ms\n
\n

Tested On

\n

Titanium SDK version: 1.6.0 (02/02/11 15:22 a02f7db...)
\nOccurs on Android Simulator 2.2

{html}", "updateAuthor": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "created": "2011-04-15T03:35:34.000+0000", "updated": "2011-04-15T03:35:34.000+0000" }, { "id": "129942", "author": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "body": "{html}

(from [2b9fd7dae1c45c8bf55b0d930659494c05ec3ebc])\n[#3052 state:fixed-in-qa] change File write to\nreturn a boolean value

\n

changed write method on file object to return a boolean value\nindicating whether the write was successful or not
\n\nhttps://github.com/appcelerator/titanium_mobile/commit/2b9fd7dae1c4...

{html}", "updateAuthor": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "created": "2011-04-15T03:35:36.000+0000", "updated": "2011-04-15T03:35:36.000+0000" }, { "id": "129943", "author": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "body": "{html}

Please verify fix with the attached app.s. When running, you\nshould see:

\n

03-16 20:01:48.546: INFO/ALERT(437): (kroll$1: app://app.js)\n[2717,13782] PASS: I wrote to a file! YESSS!

{html}", "updateAuthor": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "created": "2011-04-15T03:35:36.000+0000", "updated": "2011-04-15T03:35:36.000+0000" }, { "id": "129944", "author": { "name": "nhuynh", "key": "nhuynh", "displayName": "Natalie Huynh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Tested with Titanium SDK version: 1.7.0 (03/16/11 13:28 2b9fd7d)\non
\nNexus S 2.3.2
\nI/ALERT ( 1071): (kroll$3: app://app.js) [323,396] PASS: I wrote to\na file! YESSS!
\nEmulator 2.1
\n[TRACE] I/ALERT ( 275): (kroll$1:\napp://app.js) [430,772] PASS: I wrote to a file! YESSS!

{html}", "updateAuthor": { "name": "nhuynh", "key": "nhuynh", "displayName": "Natalie Huynh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:35:36.000+0000", "updated": "2011-04-15T03:35:36.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }