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 8067851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:28:04+00:00 2026-06-05T12:28:04+00:00

I have updated the following code to following line changes but did not work:

  • 0

I have updated the following code to following line changes but did not work:

//set the Image location

File file = new File(Environment.getExternalStorageDirectory() + "/Skynet/images/t1.jpg" );

Uri uriTarget = Uri.fromFile(file);

I want to save the jpeg to the above directory, but do not know since it is using the media store. Any tip to do this.

import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class AndroCamera extends Activity {
   private static final int IMAGE_CAPTURE = 0;
   private Button startBtn;
   private Uri imageUri;
   private ImageView imageView;

/** Called when the activity is first created.
 *  sets the content and gets the references to
 *  the basic widgets on the screen like
 *  {@code Button} or {@link ImageView}
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    imageView = (ImageView)findViewById(R.id.img);
    startBtn = (Button) findViewById(R.id.startBtn);
    startBtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            startCamera();
        }
    });
}

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);
}

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == IMAGE_CAPTURE) {
        if (resultCode == RESULT_OK){
            Log.d("ANDRO_CAMERA","Picture taken!!!");
            imageView.setImageURI(imageUri);
        }
    }
}

}

  • 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-06-05T12:28:05+00:00Added an answer on June 5, 2026 at 12:28 pm

    thats because the Uri you are using is from the media manager, perhaps if you use the defined Uri you want it to be saved to, it should work.
    Here is a hint:

    mImageUri= Uri.fromFile( new File( Environment.getExternalStorageDirectory(),
                            "pic_" + String.valueOf( System.currentTimeMillis() ) + ".jpg" ) );
    

    in this it was saved to the root, but since you are creating the file, then you can place it wherever you want to. Just make sure the directory exist otherwise create it.
    And as @Simon said, make sure you have the permission to write on external storage.

    Update 1:
    currently you have something like:

    imageUri = getContentResolver().insert(
                MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
    

    so the insert is only inserting the image to the MediaStore table… but if thats what you actually need, then you need to override the Data column in MediaStore.
    adding on your contentValues something like this:

    values.put( MediaStore.Images.ImageColumns.DATA, fullPath );
    

    if you do not need to use the MediaStore table then there is no need to do the insert and therefore the ContentValues aren’t needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: UPDATE myTable SET Col1 = @Value However, I have
I have the following code: $SQL = UPDATE jobs SET read = '1' WHERE
My issue is I have changed a file e.g.: README, added a new line
I have to execute the following query in Android SQLite UPDATE player SET rank=rank+1
Update: This does work, I was being stupid :( i have the following extension
i have the following jquery code: $(document).ready(function() { $('.restrictiveOptions input[type!=checkbox], .restrictiveOptions select').change(function() { //
I have the following code in my Ajax, which executes a page reload function
is there any way to do the following. so i have a project.jar file,
I have following simple HTML and JS code. When User selects Italian Language option
I have the following jQuery code to execute when I click a button $('#substat').click(function()

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.