Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20440] Android 6.0: writing to applicationDataDirectory fails without External storage permissions

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-03-21T08:07:24.000+0000
Affected Version/sn/a
Fix Version/sRelease 5.4.0, Release 5.3.0
ComponentsAndroid
Labelsn/a
ReporterManuel Lehner
AssigneeHieu Pham
Created2016-02-15T10:44:46.000+0000
Updated2017-05-12T06:09:00.000+0000

Description

Before targeting API 23 on Android this function worked fine for storing remote images in the applicationDataDirectory:
function onImageLoad(e){
  var imageDir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,'images/cache');
  if (! imageDir.exists()) {
      imageDir.createDirectory();
  }
  
  var image = _.last(e.source.image.split('/'));

  var localFile = Ti.Filesystem.getFile(imageDir.resolve(), image);
  localFile.write(e.source.toBlob());
  
  e.source.removeEventListener('load', onImageLoad);
}
With Titanium 5.2.0 targeting Android API >= 23 : file.write does not work throwing this error:
[ERROR] TiFileProxy: (KrollRuntimeThread) [407,3676] External storage permissions missing
Writing to the __applicationDataDirectory__ should not require this permission. *Expected* file.write() should work. *Result* file.write() fails with ERROR: External storage permissions missing

Attachments

FileDateSize
Screen Shot 2016-02-16 at 2.47.35 PM.png2016-02-16T08:48:07.000+000053326
Screen Shot 2016-02-17 at 11.38.49 AM.png2016-02-17T05:42:49.000+000067982

Comments

  1. Sharif AbuDarda 2016-02-16

    Hello, I tried to reproduce the issue of writing files in Android. Below is a sample code i am using. I have tested with SDK 5.2.0.v20160114021251 and in Nexus 5 Android 6.0.0. Writing to files is working as expected. See the screenshot.
       var win = Ti.UI.createWindow({
       
           backgroundColor : '#ffffff'
       
       });
       
       var button = Ti.UI.createButton({
           top : 10,
       
           width : 200,
       
           height : 50,
       
           title : "write file"
       
       });
       
       win.add(button);
       
       button.addEventListener('click', function(e) {
       
           var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'fileter.txt');
       
           f.write('writing to the file would be enough to create it');
       
           alert(f.read());
       });
       
       win.open();
       
  2. Manuel Lehner 2016-02-16

    Thank you for testing. I've just created a new clean project and tested your code on both of my devices, a Nexus 5 and Nexus 5X (both with Android 6.0.1). But I get different results. On the Nexus 5 it works as expected like shown in your screenshot. On the Nexus 5X The Alert body is empty and the console prints this error:
       [ERROR] TiFileProxy: (KrollRuntimeThread) [7799,7799] External storage permissions missing
       [ERROR] TiBlob: (KrollRuntimeThread) [14,7813] /data/user/0/com.goyya.test.alloy/app_appdata/fileter.txt: open failed: ENOENT (No such file or directory)
       [ERROR] TiBlob: java.io.FileNotFoundException: /data/user/0/com.goyya.test.alloy/app_appdata/fileter.txt: open failed: ENOENT (No such file or directory)
       [ERROR] TiBlob: 	at libcore.io.IoBridge.open(IoBridge.java:452)
       [ERROR] TiBlob: 	at java.io.FileInputStream.<init>(FileInputStream.java:76)
       [ERROR] TiBlob: 	at org.appcelerator.titanium.io.TiFile.getInputStream(TiFile.java:264)
       [ERROR] TiBlob: 	at org.appcelerator.titanium.TiBlob.getInputStream(TiBlob.java:389)
       [ERROR] TiBlob: 	at org.appcelerator.titanium.TiBlob.guessContentTypeFromStream(TiBlob.java:209)
       [ERROR] TiBlob: 	at org.appcelerator.titanium.TiBlob.loadBitmapInfo(TiBlob.java:270)
       [ERROR] TiBlob: 	at org.appcelerator.titanium.TiBlob.blobFromFile(TiBlob.java:140)
       [ERROR] TiBlob: 	at org.appcelerator.titanium.TiBlob.blobFromFile(TiBlob.java:113)
       [ERROR] TiBlob: 	at org.appcelerator.titanium.io.TiFile.read(TiFile.java:351)
       [ERROR] TiBlob: 	at org.appcelerator.titanium.TiFileProxy.read(TiFileProxy.java:239)
       [ERROR] TiBlob: 	at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
       [ERROR] TiBlob: 	at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62)
       [ERROR] TiBlob: 	at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:918)
       [ERROR] TiBlob: 	at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1141)
       [ERROR] TiBlob: 	at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:356)
       [ERROR] TiBlob: 	at android.os.Handler.dispatchMessage(Handler.java:98)
       [ERROR] TiBlob: 	at android.os.Looper.loop(Looper.java:148)
       [ERROR] TiBlob: 	at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:118)
       [ERROR] TiBlob: Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
       [ERROR] TiBlob: 	at libcore.io.Posix.open(Native Method)
       [ERROR] TiBlob: 	at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
       [ERROR] TiBlob: 	at libcore.io.IoBridge.open(IoBridge.java:438)
       [ERROR] TiBlob: 	... 17 more
       [ERROR] TiBlob: (KrollRuntimeThread) [19,7832] /data/user/0/com.goyya.test.alloy/app_appdata/fileter.txt: open failed: ENOENT (No such file or directory)
       [ERROR] TiBlob: java.io.FileNotFoundException: /data/user/0/com.goyya.test.alloy/app_appdata/fileter.txt: open failed: ENOENT (No such file or directory)
       [ERROR] TiBlob: 	at libcore.io.IoBridge.open(IoBridge.java:452)
       [ERROR] TiBlob: 	at java.io.FileInputStream.<init>(FileInputStream.java:76)
       [ERROR] TiBlob: 	at org.appcelerator.titanium.io.TiFile.getInputStream(TiFile.java:264)
       [ERROR] TiBlob: 	at org.appcelerator.titanium.TiBlob.getInputStream(TiBlob.java:389)
       [ERROR] TiBlob: 	at org.appcelerator.titanium.TiBlob.getBytes(TiBlob.java:324)
       [ERROR] TiBlob: 	at org.appcelerator.titanium.TiBlob.getText(TiBlob.java:452)
       [ERROR] TiBlob: 	at org.appcelerator.titanium.TiBlob.toString(TiBlob.java:511)
       [ERROR] TiBlob: 	at ti.modules.titanium.TitaniumModule.alert(TitaniumModule.java:232)
       [ERROR] TiBlob: 	at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
       [ERROR] TiBlob: 	at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62)
       [ERROR] TiBlob: 	at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:918)
       [ERROR] TiBlob: 	at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1141)
       [ERROR] TiBlob: 	at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:356)
       [ERROR] TiBlob: 	at android.os.Handler.dispatchMessage(Handler.java:98)
       [ERROR] TiBlob: 	at android.os.Looper.loop(Looper.java:148)
       [ERROR] TiBlob: 	at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:118)
       [ERROR] TiBlob: Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
       [ERROR] TiBlob: 	at libcore.io.Posix.open(Native Method)
       [ERROR] TiBlob: 	at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
       [ERROR] TiBlob: 	at libcore.io.IoBridge.open(IoBridge.java:438)
       [ERROR] TiBlob: 	... 15 more
       
    Could it be this is an arm64 issue?
  3. Sharif AbuDarda 2016-02-17

    Hello, I tested again in Nexus 5X Android 6.0.0. The issue is not reproducible. Writing to files is working as expected. See the screenshot.
  4. Manuel Lehner 2016-02-17

    It's because you've granted the Storage permission. Can you please disable this permission in the Settings and try again? This is the problem I'm trying to point out. The File Proxy should distinguish between internal and external storage. Writing into *applicationDataDirectory* does not require READ_EXTERNAL_STORAGE permission but it checks for it and fails though.
  5. Manuel Lehner 2016-02-18

    Not sure if this may be related to this issue but sometimes my app crashes with this exception:
       02-18 14:22:34.907: E/AndroidRuntime(29091): FATAL EXCEPTION: AsyncTask #1
       02-18 14:22:34.907: E/AndroidRuntime(29091): Process: com.goyya.fde, PID: 29091
       02-18 14:22:34.907: E/AndroidRuntime(29091): java.lang.NullPointerException: Attempt to invoke virtual method 'int android.app.Activity.checkSelfPermission(java.lang.String)' on a null object reference
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at org.appcelerator.titanium.util.TiFileHelper2.hasStoragePermission(TiFileHelper2.java:89)
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at org.appcelerator.titanium.util.TiResponseCache.get(TiResponseCache.java:314)
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at com.android.okhttp.internal.huc.CacheAdapter.getJavaCachedResponse(CacheAdapter.java:103)
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at com.android.okhttp.internal.huc.CacheAdapter.get(CacheAdapter.java:47)
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:229)
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:437)
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:388)
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:501)
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java)
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at com.facebook.GraphResponse.fromHttpConnection(GraphResponse.java:253)
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at com.facebook.GraphRequest.executeConnectionAndWait(GraphRequest.java:1255)
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at com.facebook.GraphRequest.executeBatchAndWait(GraphRequest.java:1157)
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at com.facebook.GraphRequest.executeBatchAndWait(GraphRequest.java:1124)
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at com.facebook.GraphRequest.executeBatchAndWait(GraphRequest.java:1108)
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at com.facebook.GraphRequest.executeAndWait(GraphRequest.java:1083)
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at com.facebook.GraphRequest.executeAndWait(GraphRequest.java:977)
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at com.facebook.internal.Utility.getAppSettingsQueryResponse(Utility.java:868)
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at com.facebook.internal.Utility.access$1(Utility.java:860)
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at com.facebook.internal.Utility$1.run(Utility.java:797)
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       02-18 14:22:34.907: E/AndroidRuntime(29091): 	at java.lang.Thread.run(Thread.java:818)
       
  6. Wilson Liaw 2016-02-22

    Yes, I can confirm this External storage permissions problem on nexus 9, it works on SDK <= 5.1.2, but not 5.2.0
  7. Soumya Kanti Kar 2016-02-29

    Not trying to be rude or pushy, can we expect the fix for this in 5.3.0. or along with the Google Play Store X509 security fix? :) We do not want to add the external storage permission as a fix as it would give wrong impression to the user.
  8. Francesco Strazzante 2016-03-03

    Hello, I've the same problem on Moto X Play (XT1562) with Android 6.0 and SDK 5.2.0GA with or without Android External Permission. The same code works on Xiaomi MI-4C with MIUI 6.1.28 (Android 5.1.1) without user permission and SDK 5.2.0GA. var photo = Ti.Network.createHTTPClient(); photo.open('GET', 'someurl'); photo.onload = function() { var dir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'biodiversita'); if (!dir.exists()) { dir.createDirectory(); } f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "biodiversita/name.jpg"); f.write(this.responseData); }; photo.send(); I tried to use SDK 5.1.2 without Android External Permission on the same Moto X Play and it works.
  9. Hieu Pham 2016-03-16

    master PR: https://github.com/appcelerator/titanium_mobile/pull/7858
  10. Ashraf Abu 2016-03-17

    [~manuellehner] Your crash log earlier with regards to
        02-18 14:22:34.907: E/AndroidRuntime(29091): FATAL EXCEPTION: AsyncTask #1
        02-18 14:22:34.907: E/AndroidRuntime(29091): Process: com.goyya.fde, PID: 29091
        02-18 14:22:34.907: E/AndroidRuntime(29091): java.lang.NullPointerException: Attempt to invoke virtual method 'int android.app.Activity.checkSelfPermission(java.lang.String)' on a null object reference
        02-18 14:22:34.907: E/AndroidRuntime(29091): 	at org.appcelerator.titanium.util.TiFileHelper2.hasStoragePermission(TiFileHelper2.java:89)
        
    is due to another issue which is solved in TIMOB-20434. The fix is in 5.2.0. Just fyi.
  11. Peter Ladis 2016-03-18

    I am on a nexus 7 with android 6.0.....I am running SDK 5.2.0 and keep getting these error. [ERROR] : TiFileProxy: (KrollRuntimeThread) [11,30395] External storage permissions missing. Do we know when this is fixed?
  12. Ashraf Abu 2016-03-21

    [~peterladis] Is your code similar to what's being mentioned in this ticket?
  13. Ashraf Abu 2016-03-21

    Master PR https://github.com/appcelerator/titanium_mobile/pull/7858 Merged. And PR https://github.com/appcelerator/titanium_mobile/pull/7871 for fixing tests Merged.
  14. Fokke Zandbergen 2016-03-21

    [~msamah] what version(s) are we fixing this in?
  15. Ashraf Abu 2016-03-21

    [~fokkezb] Thanks for pointing that out. This is in master, fix version is -6.0.0.- 5.4.0. (Incorrectly mentioned it to be 6.0.0.)
  16. Andrey Tkachenko 2016-03-22

    I got same error with Titanium.Filesystem.tempDirectory and why it not fixed for 5.2.1 ?
  17. Ashraf Abu 2016-03-22

    [~falko] Thanks for bringing this up. 5.2.1 is already scheduled and it's too late to bring this into that. Instead, we'll add this to the next patch (5.3.0).
  18. Andrey Tkachenko 2016-03-22

    OK. This PR has fix for Titanium.Filesystem.tempDirectory or Titanium.Filesystem.applicationDataDirectory only?
  19. Ashraf Abu 2016-03-22

    This fix is for applicationDataDirectory but it also works for the tempDirectory. Sample code:-
        var win = Ti.UI.createWindow({
            backgroundColor : '#ffffff'
        });
        var button = Ti.UI.createButton({
            top : 10,
            width : 200,
            height : 50,
            title : "write file"
        });
        win.add(button);
        button.addEventListener('click', function(e) {
            var f = Ti.Filesystem.getFile(Ti.Filesystem.tempDirectory, 'fileter.txt');
            f.write('writing to the file would be enough to create it');
            alert(f.read());
        });
         
        win.open();
        
    Permission is not required.
  20. Ashraf Abu 2016-03-22

    5_3_X PR: https://github.com/appcelerator/titanium_mobile/pull/7872 (Merged)
  21. Andrey Tkachenko 2016-03-22

  22. Soumya Kanti Kar 2016-03-22

    The target fix version on 5.3.0. @Ashraf Abu, can you please let us know the date by when we can expect the GA for 5.3.0. One of the new application that we are developing is targeting to save data in application data folder.
  23. Andrey Tkachenko 2016-03-22

  24. Soumya Kanti Kar 2016-03-22

    @Andrey Tkachenko Thanks for sharing the link. So we can expect the GA around Apr 11 and the RC before that, which is a good news.
  25. Andrey Tkachenko 2016-03-22

    @Soumya Kanti Kar You can add PR to 5.2.X branch and compile SDK at any time.
  26. Ashraf Abu 2016-03-23

    [~falko] based on your log it seems you are trying to use tempDirectory which TIMOB-20470 is about. In that case, please follow that jira. For the issue of this ticket of applicationDataDirectory this is resolved. Thanks!
  27. Andrey Tkachenko 2016-03-23

    @Ashraf Abu Yes I point it in my comment. But I answered to your comment.
  28. Lokesh Choudhary 2016-04-06

    Verified he fix. Writing to applicationDataDirectory doe not fail without storage permissions. Closing. Environment: Appc Studio : 4.6.0.201604041329 Ti SDK : 5.3.0.v20160404105211, 5.4.0.v20160406101605 Ti CLI : 5.0.7 Alloy : 1.8.5 MAC El Capitan : 10.11.4 Appc NPM : 4.2.5-2 Appc CLI : 5.3.0-12 Node: 4.2.2 Nexus 6 - Android 6.0.0
  29. Rainer Schleevoigt 2016-04-07

    Since Android6 you need runtime permissions. There is a module (Ti.permissions). All details on github.
  30. Fokke Zandbergen 2016-04-08

    [~titanium@webmasterei-hamburg.de] with the fixes for this ticket you shouldn't need to. Could you verify that?
  31. Rainer Schleevoigt 2016-04-08

    I never seen problems by writing to applicationdata folder.
  32. Fokke Zandbergen 2016-04-08

    OK, what exactly does your comment relate to then? {quote} Since Android6 you need runtime permissions. There is a module (Ti.permissions). All details on github. {quote}
  33. Rainer Schleevoigt 2016-04-08

    I thought the ticket was in realtion to the new perfmissions. Was mistake.
  34. Bhavin Bhavsar 2016-06-06

    Hello, I got the latest SDK- 5.3.0.GA Appcelerator Studio- 4.6.0.201605201934 Node=- V4.4.4 But, still the issue is not resolved. Below is the error.
        [ERROR] :  TiFileProxy: (KrollRuntimeThread) [6570,10154] IOException encountered
        [ERROR] :  TiFileProxy: java.io.FileNotFoundException: /storage/emulated/0/com.abc.def/others/assets.zip: open failed: EACCES (Permission denied)
        [ERROR] :  TiFileProxy: 	at libcore.io.IoBridge.open(IoBridge.java:452)
        [ERROR] :  TiFileProxy: 	at java.io.FileOutputStream.<init>(FileOutputStream.java:87)
        [ERROR] :  TiFileProxy: 	at org.appcelerator.titanium.io.TiFile.getOutputStream(TiFile.java:273)
        [ERROR] :  TiFileProxy: 	at org.appcelerator.titanium.io.TiFile.open(TiFile.java:336)
        [ERROR] :  TiFileProxy: 	at org.appcelerator.titanium.io.TiFile.write(TiFile.java:382)
        [ERROR] :  TiFileProxy: 	at org.appcelerator.titanium.TiFileProxy.write(TiFileProxy.java:285)
        [ERROR] :  TiFileProxy: 	at org.appcelerator.kroll.runtime.v8.V8Object.nativeCallProperty(Native Method)
        [ERROR] :  TiFileProxy: 	at org.appcelerator.kroll.runtime.v8.V8Object.callProperty(V8Object.java:73)
        [ERROR] :  TiFileProxy: 	at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1155)
        [ERROR] :  TiFileProxy: 	at android.os.Handler.dispatchMessage(Handler.java:98)
        [ERROR] :  TiFileProxy: 	at android.os.Looper.loop(Looper.java:158)
        [ERROR] :  TiFileProxy: 	at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:118)
        [ERROR] :  TiFileProxy: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
        [ERROR] :  TiFileProxy: 	at libcore.io.Posix.open(Native Method)
        [ERROR] :  TiFileProxy: 	at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
        [ERROR] :  TiFileProxy: 	at libcore.io.IoBridge.open(IoBridge.java:438)
        [ERROR] :  TiFileProxy: 	... 11 more
        
    All the permissions are already in tiapp.xml file. Thanks
  35. Mauro Piccotti 2016-06-06

    I've just updated all the stable versions of 2nd June and I have exactly the same problem of Bhavin Bhavsar.
  36. Jignesh Kasundra 2017-05-12

    I am getting same issue on Titanium sdk 6.0.4 , Android Platform 6.0 , Android API 23 -----------------------------
        [ERROR] :  TiFileProxy: (main) [1353,1353] IOException encountered
        [ERROR] :  TiFileProxy: java.io.FileNotFoundException: /storage/emulated/0/com.infogridpacific.sample/sample.txt: open failed: EACCES (Permission denied)
        [ERROR] :  TiFileProxy: 	at libcore.io.IoBridge.open(IoBridge.java:452)
        [ERROR] :  TiFileProxy: 	at java.io.FileOutputStream.<init>(FileOutputStream.java:87)
        [ERROR] :  TiFileProxy: 	at org.appcelerator.titanium.io.TiFile.getOutputStream(TiFile.java:273)
        [ERROR] :  TiFileProxy: 	at org.appcelerator.titanium.io.TiFile.open(TiFile.java:336)
        [ERROR] :  TiFileProxy: 	at org.appcelerator.titanium.io.TiFile.write(TiFile.java:460)
        [ERROR] :  TiFileProxy: 	at org.appcelerator.titanium.TiFileProxy.write(TiFileProxy.java:287)
        [ERROR] :  TiFileProxy: 	at org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method)
        [ERROR] :  TiFileProxy: 	at org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:196)
        [ERROR] :  TiFileProxy: 	at org.appcelerator.kroll.KrollRuntime.runModule(KrollRuntime.java:241)
        [ERROR] :  TiFileProxy: 	at org.appcelerator.titanium.TiLaunchActivity.loadActivityScript(TiLaunchActivity.java:128)
        [ERROR] :  TiFileProxy: 	at org.appcelerator.titanium.TiLaunchActivity.windowCreated(TiLaunchActivity.java:183)
        [ERROR] :  TiFileProxy: 	at org.appcelerator.titanium.TiRootActivity.windowCreated(TiRootActivity.java:172)
        [ERROR] :  TiFileProxy: 	at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:682)
        [ERROR] :  TiFileProxy: 	at org.appcelerator.titanium.TiLaunchActivity.onCreate(TiLaunchActivity.java:169)
        [ERROR] :  TiFileProxy: 	at org.appcelerator.titanium.TiRootActivity.onCreate(TiRootActivity.java:161)
        [ERROR] :  TiFileProxy: 	at android.app.Activity.performCreate(Activity.java:6237)
        [ERROR] :  TiFileProxy: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
        [ERROR] :  TiFileProxy: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
        [ERROR] :  TiFileProxy: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
        [ERROR] :  TiFileProxy: 	at android.app.ActivityThread.-wrap11(ActivityThread.java)
        [ERROR] :  TiFileProxy: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
        [ERROR] :  TiFileProxy: 	at android.os.Handler.dispatchMessage(Handler.java:102)
        [ERROR] :  TiFileProxy: 	at android.os.Looper.loop(Looper.java:148)
        [ERROR] :  TiFileProxy: 	at android.app.ActivityThread.main(ActivityThread.java:5417)
        [ERROR] :  TiFileProxy: 	at java.lang.reflect.Method.invoke(Native Method)
        [ERROR] :  TiFileProxy: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        [ERROR] :  TiFileProxy: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
        [ERROR] :  TiFileProxy: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
        [ERROR] :  TiFileProxy: 	at libcore.io.Posix.open(Native Method)
        [ERROR] :  TiFileProxy: 	at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
        [ERROR] :  TiFileProxy: 	at libcore.io.IoBridge.open(IoBridge.java:438)
        [ERROR] :  TiFileProxy: 	... 26 more
        
  37. Jignesh Kasundra 2017-05-12

    for the above error : I am writing/reading file from the external storage device. tiapp.xml ==============
                <manifest>
                    <uses-permission android:name="android.permission.INTERNET"/>
                    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
                    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
                    <application android:hardwareAccelerated="true" android:largeHeap="true"/>
                </manifest>  
        
    app.js =============
        var cameraPermission = "android.permission.CAMERA";
        var storagePermission = "android.permission.READ_EXTERNAL_STORAGE";
        var hasCameraPermission = Ti.Android.hasPermission(cameraPermission);
        var hasStoragePermission = Ti.Android.hasPermission(storagePermission);
        var permissionsToRequest = [];
        
        
        
        var win = Ti.UI.createWindow({
                title: 'mywin',
                backgroundColor: '#fff',
                width : Ti.UI.FILL,
                height : Ti.UI.FILL
        });
        
        win.open();
        
        
        if (!hasCameraPermission) {
            permissionsToRequest.push(cameraPermission);
        }
        if (!hasStoragePermission) {
            permissionsToRequest.push(storagePermission);
        }
        if (permissionsToRequest.length > 0) {
            Ti.Android.requestPermissions(permissionsToRequest, function(e) {
                if (e.success) {
                    Ti.API.info("SUCCESS");
                } else {
                    Ti.API.info("ERROR: " + e.error);
                }
            });
        }
        
        
        		var localPath = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory).nativePath;
        									
        		var sampletxtvar = Ti.Filesystem.getFile(localPath, "sample.txt");
        		sampletxtvar.write("this is my sample text");
        
        		var content = "";		
        
        		if (sampletxtvar.exists()) {
        					content = nomediatxt.read().text;
        					alert("Content is ::: " +content);
        		}
        

JSON Source