0

我是 android 新手,正在尝试制作一个 android 应用程序,用户可以在其中单击图像并将其保存到数据库中。但是我不希望图像本地存储在画廊文件夹中。或者每次拍照时它都会将自己保存在手机上的自制目录中并不断替换早期的照片。我不希望所有照片都存储在手机上。

以下是我当前的代码:

package com.example.camerastart;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public class CameraMainActivity extends Activity 
{

    private static final int CAMERA_PIC_REQUEST = 2500;
    private Button cam_button;

    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_camera_main);

        cam_button = (Button) findViewById(R.id.button1);
        cam_button.setOnClickListener(new OnClickListener()
        {

            @Override
            public void onClick(View v)
            {
                Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
                // TODO Auto-generated method stub

            }

        });
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data) 
    {
        if (requestCode == CAMERA_PIC_REQUEST && resultCode == RESULT_OK)
        {
              Bitmap image = (Bitmap) data.getExtras().get("data");
              ImageView imageview = (ImageView) findViewById(R.id.imageView1);
              imageview.setImageBitmap(image);
        }
    }




    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_camera_main, menu);
        return true;
    }

}

任何帮助将不胜感激

4

1 回答 1

0

You can make a folder, and save all the images to this folder. just remember to add .nomedia file to this folder, and then the gallery will not show those files

于 2013-09-16T10:52:19.763 回答