捕获和Android中使用不同的名称保存图像,然后通过任何这些名称的检索吗? [英] Capturing and Saving an image in Android with different names and then retrieving it by any of those names?

查看:203
本文介绍了捕获和Android中使用不同的名称保存图像,然后通过任何这些名称的检索吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Andr​​oid和已成功运行我的应用程序,我可以用相机来捕捉图像。不过,我想知道存储和检索图像的最佳解决方案。

I am new to android and have managed to run my app where I can use the camera to capture the image. However I want to know the best solution to store and retrieve the images.


  1. 这是好存储在SQLlite或外部存储器中的影像

  1. Is it good to store the images in SQLlite or External Memory

我可以存储在多个sqllite逗号分隔的名字图像,然后检索它按这些名字。

Can I store the image with multiple comma separated names in sqllite and then retrieve it as per those names.

有关如我有一个拍摄按钮,我可以点击捕捉图像,然后如果图像是好的,我可以preSS接下来它表明了我一个文本框和保存按钮。在文本框中我可以输入图像的多个名字说 - X1,X2,X3等,然后我想用这些名称的检索图片

For e.g. I have a capture button where I can click to capture an image and then if the image is okay i can press next where it shows me a text box and save button. In the text box I can enter multiple names of image say - x1, x2, x3 etc. and then i want to retrieve the image by using any of these names.

什么好主意将大大AP preciated。

any good idea will be much appreciated.

推荐答案

我想储存图像的最好办法是将其保存在外部存储器。这种方式也是最简单的方法!

I think best way to store your Images is to save it on External memory. This way is also simplest way!

下面你code的一些费用相加,以节省外部图像

Here you are some pice of code to save the image on external

public static File saveImage(Bitmap bitmap, String imageName) {
        File myDir = new File(Environment.getExternalStoragePublicDirectory(
                Environment.DIRECTORY_PICTURES), DIR);

        if (!myDir.mkdirs()) {
            Log.e(ImageUtils.class.getSimpleName(), "Directory not created");
        }

        myDir.mkdirs();
        String image = getImageName(imageName);
        File file = new File(myDir, image);

        if (file.exists())
            return null;
        try {
            FileOutputStream out = new FileOutputStream(file);
            bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
            out.flush();
            out.close();
            return file;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

我希望这将是有益的你

I hope that it will be usefull for you

这篇关于捕获和Android中使用不同的名称保存图像,然后通过任何这些名称的检索吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆