简体   繁体   English

保存在内部还是外部存储中?

[英]Save in Internal or External Storage?

I am building an app which requires pictures from camera and gallery from a drop down. 我正在构建一个应用程序,该应用程序需要下拉菜单中的相机和图库图片。 I want if the user selects camera option, the image gets saved in this file path - 我想要如果用户选择“相机”选项,图像将保存在此文件路径中-

Android/data/my_pkg_name(com.joey.imageapp)/files/user_avatars/file_name.png.

How do I create the file path and save the image there? 如何创建文件路径并将图像保存在那里? Is internal or external storage the best place to store app-images? 内部存储还是外部存储是存储应用程序映像的最佳场所? Thanks. 谢谢。

use the following code for setting the path and launching camera 使用以下代码设置路径并启动摄像头

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Uri imageuri = Uri.fromFile(new File("/your path/yourfilename.png"));
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageuri);
startActivityForResult(intent, 1);

Is internal or external storage the best place to store app-images? 内部存储还是外部存储是存储应用程序映像的最佳场所?

Internal Storage: 内部存储器:

Files saved to the internal storage are private to your application and other applications cannot access them (nor can the user). 保存到内部存储器的文件是您的应用程序专用的,其他应用程序无法访问它们(用户也不能访问它们)。 When the user uninstalls your application, these files are removed. 当用户卸载您的应用程序时,这些文件将被删除。

External Storage: 外置储存:

Files saved to the external storage are world-readable and can be modified by the user when they enable USB mass storage to transfer files on a computer. 保存到外部存储器的文件是全球可读的文件,当用户启用USB大容量存储器在计算机上传输文件时,可以对其进行修改。 Data Storage in Android Android中的数据存储

Save the image to internal directory 将图像保存到内部目录

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

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