Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7419443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:04:18+00:00 2026-05-29T08:04:18+00:00

I have an camera Activity like this: public void startCamera() { Log.d(ANDRO_CAMERA, Starting camera

  • 0

I have an camera Activity like this:

public void startCamera() 
{
    Log.d("ANDRO_CAMERA", "Starting camera on the phone...");
    String fileName = "testphoto.jpg";
    ContentValues values = new ContentValues();
    values.put(MediaStore.Images.Media.TITLE, fileName);
    values.put(MediaStore.Images.Media.DESCRIPTION,
            "Image capture by camera");
    values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
    imageUri = getContentResolver().insert(
            MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
    startActivityForResult(intent, IMAGE_CAPTURE);
}

What should I do to save this image to a SQLite database?


I have code like this:

fileName = helper.getKdStore(c) + "_" + System.currentTimeMillis() + ".jpg";
_path = Environment.getExternalStorageDirectory().toString() + "/DCIM/Camera/" + fileName;

In start camera:

Cursor c = helper.getById(almagId);
c.moveToFirst();
File file = new File(_path, null);
try {
    file.createNewFile();
} catch (IOException e) {
    e.printStackTrace();
}
Uri outputFileUri = Uri.fromFile(file);
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, IMAGE_CAPTURE);
System.out.println(file);

Dbhelper helper = new Dbhelper(this);
SQLiteDatabase db = helper.getWritableDatabase();
db.execSQL("update alfamapp set gambar ='"+file+"' where kdstore='"+helper.getKdStore(c)+"'");
db.close();
helper.close();

System.out.println(db);

and I create method public void load() to display my image:

detGam.setImageDrawable(Drawable.createFromPath(_path));

but my application can’t display the image. Thank you for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:04:19+00:00Added an answer on May 29, 2026 at 8:04 am

    Saving Image in to sqlite is bad idea, however if you still want to go further, there here is code

    public static void insertPicture(byte[] data)
    {
    
        SQLiteDatabase db = thisAct.openOrCreateDatabase(ConstantCodes.IMAGE_DATABASE, 2, null);
        ContentValues values = new ContentValues(1);
        values.put("photo", data);
        db.insert("photos", null, values);
        db.close();
    
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried starting the camera in android using an intent, something like this:
I have an Activity that launches a Camera Intent like this (nothing special): Intent
I have a camera activity. I want to make it looks like the default
I have an activity A where I'm building my own camera.In this activity the
Suppose I have the following class: class Camera { public Camera( double exposure, double
I have an Activity that opens the Camera and starts a preview on a
I have an activity that shows up when the phone screen goes to sleep/turns
I am developing a widget for turning on/off camera led of phone. I have
In my app, I have an Activity that acts as a camera preview. I
I have an activity where I start the built-in camera using onActivityResult. After taking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.