钛 - Android外部存储 - 创建新的目录,然后写入文件 [英] Titanium - Android external storage - create new directory and then write files into it
问题描述
是钛是如此受限制,即使在使用 Ti.Filesystem.externalStorageDirectory 之后也总是在内部存储器上写入文件?
是否有人能够创建在Android的SD卡上编程一个新的目录写在这里的答案或从来没有人需要写在外部SD卡上的东西吗?
您可以使用 System
类来获得像下面这样的存储变量
可以使用
字符串extStore = System.getenv(EXTERNAL_STORAGE);
文件f_exts =新文件(extStore);
要获得外部SD卡,您可以使用
字符串secStore = System.getenv(SECONDARY_STORAGE);
文件f_secs =新文件(secStore);
您可以选择创建文件夹的位置以及使用哪一个。
编辑
$ b
Environment.getExternalStorageDirectory()
/ h2>
- 返回主共享/外部存储目录
- 目录目前可能无法访问已经被用户安装在他们的计算机上,已经从设备上移除,或者发生了一些其他问题。您可以使用getExternalStorageState()来确定其当前状态。
lockquote
注意:不要被这里是外部字样。这个目录可以更好地被认为是媒体/共享存储。这是一个文件系统,可以容纳大量的数据,并在所有应用程序之间共享(不强制执行权限)。传统上,这是一个SD卡,但它也可以实现为一个设备中的内置存储器,与受保护的内部存储器不同,并可以作为文件系统安装在计算机上。
< blockquote>
来自环境
希望它能帮上忙。
Can we not simply create new directory programmatically on external SD card (not internal memory of device) in Android and can we not write files on SD card?
Is Titanium so restricted to always write files on internal memory even after using Ti.Filesystem.externalStorageDirectory?
Can someone who has ever been able to create a new directory programmatically on SD card in Android write the answer here or no one ever needs to write something on external SD card?
解决方案 You can use System
class to get storage variables like below
To get the internal SD card you can use
String extStore = System.getenv("EXTERNAL_STORAGE");
File f_exts = new File(extStore);
To get the external SD card you can use
String secStore = System.getenv("SECONDARY_STORAGE");
File f_secs = new File(secStore);
You can choose where to create folder and which one to use.
EDIT
Environment.getExternalStorageDirectory()
Details
- Return the primary shared/external storage directory.
- This directory may not currently be accessible if it has been mounted by the user on their computer, has been removed from the device, or some other problem has happened. You can determine its current state with getExternalStorageState().
Note: don't be confused by the word "external" here. This directory can better be thought as media/shared storage. It is a filesystem that can hold a relatively large amount of data and that is shared across all applications (does not enforce permissions). Traditionally this is an SD card, but it may also be implemented as built-in storage in a device that is distinct from the protected internal storage and can be mounted as a filesystem on a computer.
Reference from Environment
Hope it'll help.
这篇关于钛 - Android外部存储 - 创建新的目录,然后写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
lockquote
注意:不要被这里是外部字样。这个目录可以更好地被认为是媒体/共享存储。这是一个文件系统,可以容纳大量的数据,并在所有应用程序之间共享(不强制执行权限)。传统上,这是一个SD卡,但它也可以实现为一个设备中的内置存储器,与受保护的内部存储器不同,并可以作为文件系统安装在计算机上。
< blockquote>
来自环境
希望它能帮上忙。
Can we not simply create new directory programmatically on external SD card (not internal memory of device) in Android and can we not write files on SD card?
Is Titanium so restricted to always write files on internal memory even after using Ti.Filesystem.externalStorageDirectory?
Can someone who has ever been able to create a new directory programmatically on SD card in Android write the answer here or no one ever needs to write something on external SD card?
You can use System
class to get storage variables like below
To get the internal SD card you can use
String extStore = System.getenv("EXTERNAL_STORAGE");
File f_exts = new File(extStore);
To get the external SD card you can use
String secStore = System.getenv("SECONDARY_STORAGE");
File f_secs = new File(secStore);
You can choose where to create folder and which one to use.
EDIT
Environment.getExternalStorageDirectory()
Details
- Return the primary shared/external storage directory.
- This directory may not currently be accessible if it has been mounted by the user on their computer, has been removed from the device, or some other problem has happened. You can determine its current state with getExternalStorageState().
Note: don't be confused by the word "external" here. This directory can better be thought as media/shared storage. It is a filesystem that can hold a relatively large amount of data and that is shared across all applications (does not enforce permissions). Traditionally this is an SD card, but it may also be implemented as built-in storage in a device that is distinct from the protected internal storage and can be mounted as a filesystem on a computer.
Reference from Environment
Hope it'll help.
这篇关于钛 - Android外部存储 - 创建新的目录,然后写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!