我要救从camera
到extSdcard
捕获image
,但问题的images
储存在我的手机的internal memory
有android 4.4.4(kitkat)
和android 5.1.1
但android 4.2
图像已经存储在extsdcard
,你有什么这个想法请吗?保存拍摄的图像,以SD卡
1
A
回答
0
根据Document
应用不得被允许写入第二外部存储 设备,除了在
可以编写到应用特定的文件夹上primary external storage
即,它们的具体包/sdcard/Android/data/package/
和secondary external storage
的应用程序特定文件夹即/extSdcard/Android/data/package/
和WRITE_EXTERNAL_STORAGE
您可以写信给所有位置primary external storage
即/sdcard/
bu t您无法写入secondary
external storage
(应用程序特定文件夹除外)上的任何位置。
+0
我试过这个,但它不工作! – rheema
0
所以我必须创建一个文件夹与我的应用程序包的名称,但在我的应用程序的代码中,我必须做一个更改或不?这是我的代码
Button captureButton = (Button) findViewById(R.id.button_capture);
captureButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCamera.takePicture(null, null, mPicture);
}
/**
* Helper method to access the camera returns null if it cannot get the
* camera or does not exist
*
* @return
*/
private Camera getCameraInstance() {
Camera camera = null;
try {
camera = Camera.open();
} catch (Exception e) {
// cannot get camera or does not exist
}
return camera;
}
PictureCallback mPicture = new PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
File pictureFile = getOutputMediaFile();
if (pictureFile == null) {
return;
}
try {
pictureFile.createNewFile();
FileOutputStream fos = new FileOutputStream(pictureFile);
fos.write(data);
fos.close();
} catch (FileNotFoundException e) {
} catch (IOException e) {
}
}
};
private static File getOutputMediaFile() {
File mediaStorageDir = new File(Environment.getExternalStorageDirectory() + "/MyCameraApp/");
if (!mediaStorageDir.exists()) {
mediaStorageDir.mkdir();
}
return mediaStorageDir;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
return true;
}
private String currentDateFormat(){
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HH_mm_ss");
String currentTimeStamp = dateFormat.format(new Date());
return currentTimeStamp;
}
}
相关问题
- 1. 保存拍摄的图像
- 2. 保存拍摄图像
- 3. 如何在不保存SD卡的情况下从相机拍摄图像?
- 4. 如何拍摄并存入SD卡?
- 5. 问题调用摄像头并保存SD卡中的图像
- 6. 摄像头图像被保存到SD卡作为空文件?
- 7. 拍摄照片并保存在SD卡或相机相册PHONEGAP
- 8. Android相机拍摄照片时不保存到SD卡
- 9. 保存图像视图中的SD卡
- 10. 在phonegap应用程序中保存SD卡中的相机拍摄的图片
- 11. AVCam Libriary拍摄图像保存
- 12. 拍照并保存到SD卡
- 13. Android的图像保存到SD卡
- 14. 要保存图像中的SD卡
- 15. Android的保存捕捉的图像以Android相机拍摄的
- 16. 下载并保存图像到SD卡
- 17. Android将图像保存在SD卡中
- 18. 电晕图像保存到SD卡
- 19. 将图像保存到SD卡
- 20. 保存已放置图像到SD卡
- 21. 保存缩放图像SD卡android
- 22. 用相机保存图像叠加拍摄的图像underneith
- 23. 卡布奇诺 - 从CPView拍摄图像
- 24. 如何在PhoneGap的移动拍摄的图像文件夹中的SD卡
- 25. 拍摄后拍摄的图像拍摄后:Swift
- 26. 保存图像并复制SD卡中的所有图像
- 27. 告诉相机意图保存拍摄的图像
- 28. 如何拍摄高质量的截图/保存图像?
- 29. 从SD卡中取出图像,压缩并保存回SD?
- 30. 如何在Android中拍摄照片或SD卡后获取图像名称
由于Android 4.4你不能写二级/移动存储。 –
https://commonsware.com/blog/2014/04/09/storage-situation-removable-storage.html – CommonsWare
有没有解决方案!我想存储许多图片,内部存储器不是解决方案! – rheema