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

  • SEARCH
  • Home
  • 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 8168633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:35:30+00:00 2026-06-06T20:35:30+00:00

I am using the PhoneGap camera API to take a picture. After taking the

  • 0

I am using the PhoneGap camera API to take a picture. After taking the picture, it will be displayed in my page. It works, but pictures are saved in the application cache folder,

/mnt/sdcard/Android/data/mypackage.com/cache.

Instead, I want to save them in a folder in my SD card, /mnt/sdcard/myFolder, or something like that. I have gone through lot of Q&A, but I couldn’t find the way I want.

Here is my source code.

  <html>
     <div data-role="page" id="camera_page" data-theme="a">
        <div data-role="header"><h1>Camera-page</h1></div>
        <div data-role="content" class="ui-content">
        <div data-role="fieldcontain">
        <button onclick="capturePhotoWithData();" data-theme="a">Capture Photo</button> <br>

            <img style="display:none;width:60px;height:60px;" id="smallImage" src="" />
            <img style="display:none;" id="largeImage" src="" />
        </div>

    </div>
    <div data-role="footer" data-position="fixed">footer</div>
</div>

</html>

//here is my  java script

  <script type="text/javascript">

  var pictureSource;   // picture source
  var destinationType; // sets the format of returned value 

  // Wait for PhoneGap to connect with the device
   //
   document.addEventListener("deviceready",onDeviceReady,false);

 // PhoneGap is ready to be used!
  //
 function onDeviceReady() {
    pictureSource=navigator.camera.PictureSourceType;
    destinationType=navigator.camera.DestinationType;
}

// Called when a photo is successfully retrieved
//
function onPhotoDataSuccess(imageData) {
  // Get image handle
  //
  var smallImage = document.getElementById('smallImage');

  // Unhide image elements
  //
  smallImage.style.display = 'block';

  // Show the captured photo
  // The inline CSS rules are used to resize the image
  //
  smallImage.src = "data:image/jpeg;base64," + imageData;
}

// Called when a photo is successfully retrieved
//
function onPhotoFileSuccess(imageData) {
  // Get image handle
  console.log(JSON.stringify(imageData));

  // Get image handle
  //
  var smallImage = document.getElementById('smallImage');

  // Unhide image elements
  //
  smallImage.style.display = 'block';

  // Show the captured photo
  // The inline CSS rules are used to resize the image
  //
  smallImage.src = imageData;
}

// Called when a photo is successfully retrieved
//
function onPhotoURISuccess(imageURI) {
  // Uncomment to view the image file URI 
  // console.log(imageURI);

  // Get image handle
  //
  var largeImage = document.getElementById('largeImage');

  // Unhide image elements
  //
  largeImage.style.display = 'block';

  // Show the captured photo
  // The inline CSS rules are used to resize the image
  //
  largeImage.src = imageURI;
}

// A button will call this function
//
function capturePhotoWithData() {
  // Take picture using device camera and retrieve image as base64-encoded string
  navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50 });
}

function capturePhotoWithFile() {
    navigator.camera.getPicture(onPhotoFileSuccess, onFail, { quality: 50, destinationType: Camera.DestinationType.FILE_URI });
}

// A button will call this function
//
function getPhoto(source) {
  // Retrieve image file location from specified source
  navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50, 
    destinationType: destinationType.FILE_URI,
    sourceType: source });
}

// Called if something bad happens.
// 
function onFail(message) {
  alert("you didn't take any pictures");
}

  • 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-06T20:35:32+00:00Added an answer on June 6, 2026 at 8:35 pm

    Using an OnActivityResult method checking for the correct result ID,

    String out = "/mnt/sdcard/myFolder/mypic.png";
    Bitmap b = i.getExtras().getData("data");
    
    //Create an OutputStream, can't remember how I did it.  this.getOutputStream() maybe?
    
    Bitmap.compress(Bitmap.CompressFormat.valueOf(out), 100, outputStream);
    

    I’ve done this in a project at work, I may be able to update you exactly how tomorrow.

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

Sidebar

Related Questions

In my PhoneGap/jQuery Mobile app, I'm currently using PhoneGaps' Camera API to allow the
I have tried to upload image using FileTransfer.upload in phonegap api.But I am getting
I'm using Phonegap (Cordova for iOS) with XCode and I'm using the Camera API
I am having some problems with Phonegap and the Android Camera API. I can
I am using phonegap in my application. using camera plugin for capture and select
I am trying out the Camera API for Phonegap and I have ran into
I'm using PhoneGap's navigator.camera.getPicture function to retrieve a photo from the device's camera on
I am developing an Application using Phonegap on Android. Everything works fine on OS
I am using phonegap file api to create a directory and create a file
I have a HTML/Javascript web application which integrates with a device's camera using PhoneGap.

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.