Nativescript: Android File System Access

Created on 28 Jun 2015  路  2Comments  路  Source: NativeScript/NativeScript

What does the built in file system for Nativescript allow us to do? As I understand it only allows us to access private files which are pertinent and private to the app? Is there any way to access external storage using the file-system api?

Most helpful comment

Built-in file access does not grant access to some directories or files. It is just a module that simplifies a little bit working with files and directories. If your application has permissions to write or read something stored on the external storage then you could use file-system api. I don't know if that will help, but there is an example (from camera module) how to use external storage.

var appModule = require("application");
var tempPicturePath = fileSystem.path.join(appModule.android.currentContext.getExternalFilesDir(null).getAbsolutePath(), "cameraPicture_" + dateStamp + ".jpg");
var nativeFile = new java.io.File(tempPicturePath);
var tempPictureUri = android.net.Uri.fromFile(nativeFile);
takePictureIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, tempPictureUri);

All 2 comments

Built-in file access does not grant access to some directories or files. It is just a module that simplifies a little bit working with files and directories. If your application has permissions to write or read something stored on the external storage then you could use file-system api. I don't know if that will help, but there is an example (from camera module) how to use external storage.

var appModule = require("application");
var tempPicturePath = fileSystem.path.join(appModule.android.currentContext.getExternalFilesDir(null).getAbsolutePath(), "cameraPicture_" + dateStamp + ".jpg");
var nativeFile = new java.io.File(tempPicturePath);
var tempPictureUri = android.net.Uri.fromFile(nativeFile);
takePictureIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, tempPictureUri);

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings