0

I would like to know if an Android app using Cordova can write in the folder that it is installed in. Basically, I need this to update the app without having to go through the app store.

In iOS, ressources files are copied in a sandboxed environment and I cannot write to it. What about in Android?

mc9
  • 6,121
  • 13
  • 49
  • 87
  • you can on ios and on android. sandboxed means you can't write ouside of it, but you can write inside. you can search the conten sync plugin, it does what you want – jcesarmobile Oct 21 '15 at 13:18

1 Answers1

0

Yes ,cordova can write into the app folder or in anyfile which it Android can access , if you want to write in private other folder that wont be possible .

For cordova you need to just add a plugin for accessing the storage or create a custom plugin for the same.

Below is code for writing into your App Folder :

if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
        Log.d("Log", "No sdcard available");
} else {
    File directory = new File(Environment.getExternalStorageDirectory()+File.separator+"ApplicationFolderName");
    directory.mkdirs();
}

Make sure you add permission into manifest file also.

KOTIOS
  • 11,177
  • 3
  • 39
  • 66
  • Thanks. Your example code only concerns the external storage. What about the internal storage? Or for that matter, the actual location where the hybrid app exists in Android? – mc9 Oct 21 '15 at 07:06
  • yes that will also do , cordova can do everything with android device which android native itslef can do hence checkout this :http://stackoverflow.com/questions/5766609/save-internal-file-in-my-own-internal-folder-in-android – KOTIOS Oct 21 '15 at 07:16
  • From my understanding, `data` folder is writable in Android. But I want to modify the contents in the app folder. Are you sure it is possible to write in the actual app folder? That sounds like a security threat. – mc9 Oct 21 '15 at 07:35
  • modifying the contents i m not sure but yes you can create new file in ur own app dir which is in internal storage . – KOTIOS Oct 21 '15 at 07:42