Java 如何将捕获的图像保存到内部存储器

Java 如何将捕获的图像保存到内部存储器,java,android,eclipse,android-studio,local-storage,Java,Android,Eclipse,Android Studio,Local Storage,嗨,伙计们,我想在我的相机应用程序中添加一个选项,当用户打开一个应用程序时,会出现一个弹出窗口,其中有一个保存捕获图像的选项,弹出窗口需要包括相机默认存储文件夹的子文件夹,还有一个创建新文件夹和重命名选项,然后按enter键,无论他捕获的是什么,都将保存在同一文件夹中,一旦他想将图像保存到下一个文件夹中,用户应该能够从应用程序栏中的设置中进行选择,当按下该设置时,将显示相同的弹出窗口,并带有一个选项,用于将捕获的图像保存到同一子文件夹的位置 我的主要活动包括 package com.e

嗨,伙计们,我想在我的相机应用程序中添加一个选项,当用户打开一个应用程序时,会出现一个弹出窗口,其中有一个保存捕获图像的选项,弹出窗口需要包括相机默认存储文件夹的子文件夹,还有一个创建新文件夹和重命名选项,然后按enter键,无论他捕获的是什么,都将保存在同一文件夹中,一旦他想将图像保存到下一个文件夹中,用户应该能够从应用程序栏中的设置中进行选择,当按下该设置时,将显示相同的弹出窗口,并带有一个选项,用于将捕获的图像保存到同一子文件夹的位置

我的主要活动包括



package com.example.sairamkrishna.myapplication;
导入android.Manifest;
导入android.app.Activity;
导入android.app.AlertDialog;
导入android.content.Context;
导入android.content.DialogInterface;
导入android.content.Intent;
导入android.content.SharedReferences;
导入android.content.pm.PackageManager;
导入android.net.Uri;
导入android.os.Bundle;
导入android.provider.Settings;
导入android.support.v4.app.ActivityCompat;
导入android.support.v4.content.ContextCompat;
导入android.support.v7.app.AppActivity;
导入android.support.v7.widget.Toolbar;
公共类MainActivity扩展了AppCompatActivity{
公共静态最终int MY\u权限\u请求\u摄像头=100;
公共静态最终字符串ALLOW\u KEY=“ALLOWED”;
公共静态最终字符串CAMERA\u PREF=“CAMERA\u PREF”;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if(ContextCompat.checkSelfPermission(this,Manifest.permission.CAMERA)!=PackageManager.permission\u已授予){
if(getFromPref(此,允许_键)){
showSettingsAlert();
}else if(ContextCompat.checkSelfPermission)(此,
舱单、许可、摄像头)
!=PackageManager.权限(已授予){
//我们应该解释一下吗?
如果(活动公司)应显示请求许可理由(此,
舱单,许可,摄像机){
showarert();
}否则{
//不需要解释,我们可以申请许可。
ActivityCompat.requestPermissions(此,
新字符串[]{Manifest.permission.CAMERA},
我的(许可)(请求)(相机);;
}
}
}否则{
openCamera();
}
}
公共静态void saveToPreferences(上下文上下文、字符串键、允许布尔值){
SharedPreferences myPrefs=context.getSharedPreferences(CAMERA_PREF,
上下文。模式(私人);
SharedReferences.Editor prefsEditor=myPrefs.edit();
prefsEditor.putBoolean(键,允许);
提交();
}
公共静态布尔getFromPref(上下文,字符串键){
SharedPreferences myPrefs=context.getSharedPreferences(CAMERA_PREF,
上下文。模式(私人);
返回(myPrefs.getBoolean(key,false));
}
私有void showAlert(){
AlertDialog AlertDialog=新建AlertDialog.Builder(MainActivity.this.create();
alertDialog.setTitle(“警报”);
setMessage(“应用程序需要访问摄像头。”);
alertDialog.setButton(alertDialog.BUTTON_否定,“不允许”,
新建DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int which){
dialog.dismise();
完成();
}
});
alertDialog.setButton(alertDialog.BUTTON_正“允许”,
新建DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int which){
dialog.dismise();
ActivityCompat.requestPermissions(MainActivity.this,
新字符串[]{Manifest.permission.CAMERA},
我的(许可)(请求)(相机);;
}
});
alertDialog.show();
}
私有void showSettingsAlert(){
AlertDialog AlertDialog=新建AlertDialog.Builder(MainActivity.this.create();
alertDialog.setTitle(“警报”);
setMessage(“应用程序需要访问摄像头。”);
alertDialog.setButton(alertDialog.BUTTON_否定,“不允许”,
新建DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int which){
dialog.dismise();
//完成();
}
});
alertDialog.setButton(alertDialog.BUTTON_正,“设置”,
新建DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int which){
dialog.dismise();
startInstalledAppDetailsActivity(MainActivity.this);
}
});
alertDialog.show();
}
@凌驾
public void onRequestPermissionsResult(int-requestCode,字符串权限[],int[]grantResults){
开关(请求代码){
案例我的\u权限\u请求\u摄像头:{
for(int i=0,len=permissions.length;iwindow.localStorage.setItem("itemName", item); // to save it in your phone
window.localStorage.getItem("itemName"); // to retrieve your item