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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:51:30+00:00 2026-06-11T08:51:30+00:00

I have Written the code to store the bitmap Image in sdcard But I

  • 0

I have Written the code to store the bitmap Image in sdcard But I want to store it along with the date time stamp .How to do it ?

bmp = processFrame(mCamera);
                String i1=bmp.toString();
                String root = Environment.getExternalStorageDirectory().toString();
                File myDir = new File(root + "/saved_images");    
                    myDir.mkdirs();
                    Random generator = new Random();
                    int n = 10000;
                    n = generator.nextInt(n);
                    String fname = "Image-"+ n +".jpg";
                    File file = new File (myDir, fname);
                    if (file.exists ()) file.delete (); 
                    try {
                           FileOutputStream out = new FileOutputStream(file);
                           bmp.compress(Bitmap.CompressFormat.JPEG, 90, out);
                           out.flush();
                           out.close();

                    } catch (Exception e) {
                           e.printStackTrace();
                    }
  • 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-11T08:51:31+00:00Added an answer on June 11, 2026 at 8:51 am

    use this

    String fname = "Image-"+ n +System.currentTimeMillis() +".jpg";
    

    instead of

    String fname = "Image-"+ n +".jpg";
    

    try this :

    String getCurrentDate() {
            Calendar c = Calendar.getInstance();
            String Month = "";
            switch (c.get(Calendar.MONTH)) {
            case 0:
                  Month = "Jan";
                  break;
            case 1:
                  Month = "Feb";
                  break;
            case 2:
                  Month = "Mar";
                  break;
            case 3:
                  Month = "Apr";
                  break;
            case 4:
                  Month = "May";
                  break;
            case 5:
                  Month = "June";
                  break;
            case 6:
                  Month = "July";
                  break;
            case 7:
                  Month = "Aug";
                  break;
            case 8:
                  Month = "Sep";
                  break;
            case 9:
                  Month = "Oct";
                  break;
            case 10:
                  Month = "Nov";
                  break;
            case 11:
                  Month = "Dec";
                  break;
            default:
                  break;
            }
            int ampm = c.get(Calendar.AM_PM);
            String amorpm = "";
            if (ampm == 1) {
                  amorpm = "PM";
            } else {
                  amorpm = "AM";
            }
            String date = c.get(Calendar.DAY_OF_MONTH) + "/" + Month + "/"
                        + c.get(Calendar.YEAR) + " " + c.get(Calendar.HOUR) + ":"
                        + c.get(Calendar.MINUTE) + " " + amorpm;
            // int Day = c.get(Calendar.DAY_OF_MONTH);
            // int month = c.get(Calendar.MONTH);
            return date;
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a code for store the current date & time value. It
I want to store bitmap image on internal storage (not external storage). I have
I have written code in Java to access web cam,and to save image... I
I have written some code for displaying a drop down list, but the code
I have written some simple and working assembly code on 8085 trainer hardware. But
Below is the code that I have written. I want to do the simple
I have written a code to read a file, store it in a structure
I have written some code that works pretty well, but I have a strange
I have written code to store some headline's from news websites in a database.
I have written code that opens 16 figures at once. Currently, they all open

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.