简体   繁体   English

如何在Galaxy Nexus上存储以编程方式创建的文件?

[英]How to store programmatically created files on Galaxy Nexus?

I want to create an application to capture videos and store the captured videos on the sdcard. 我想创建一个应用程序来捕获视频并将捕获的视频存储在sdcard上。 But Nexus does not have an sdcard so the application gives me an exception and says: 但是Nexus没有sdcard,因此该应用程序给了我一个例外,并说:

Unfortunately the application has closed. 不幸的是,该应用程序已关闭。

I tried saving the captured videos on the internal memory but cannot access the videos. 我尝试将捕获的视频保存在内部存储器中,但是无法访问视频。 Also the videos are not listed in the device gallery. 此外,视频未在设备库中列出。

Where should an application store the data on a Nexus device? 应用程序应将数据存储在Nexus设备上的什么位置?

Galaxy Nexus does have a mount to the sdcard using Galaxy Nexus确实通过以下方式将其安装到sdcard

/mnt/shell/emulated/0

see here for gory details on the mounts... 参见这里以获得安装座上的血腥细节...

You could also store your app files in the folder returned by 您也可以将应用程序文件存储在由返回的文件夹中

ContextWrapper.getFilesDir()

that path will be something like:- 该路径将类似于:

/data/data/$YOUR.PACKAGE/files

use Environment.getExternalStorageDirectory().getPath() to get a path to the external storage on any given device. 使用Environment.getExternalStorageDirectory().getPath()获取到任何给定设备上的外部存储的路径。 You should be using this instead of hardcoding /sdcard/ 您应该使用它而不是对/sdcard/进行硬编码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM