smither123
smither123

Reputation: 357

Android: Cannot resolve constructor 'Date()'

I'm getting this error "Cannot resolve constructor 'Date()'" and i don't know why.

If someone could explain why i'm getting it, i would be grateful.

Thank you

Code:

/** Create a File for saving an image or video */
    private  File getOutputMediaFile(){
        // To be safe, you should check that the SDCard is mounted
        // using Environment.getExternalStorageState() before doing this.
        File mediaStorageDir = new File(Environment.getExternalStorageDirectory()
                + "/Android/data/"
                + getApplicationContext().getPackageName()
                + "/Files");

        // This location works best if you want the created images to be shared
        // between applications and persist after your app has been uninstalled.

        // Create the storage directory if it does not exist
        if (! mediaStorageDir.exists()){
            if (! mediaStorageDir.mkdirs()){
                return null;
            }
        }
        // Create a media file name
        String timeStamp = new SimpleDateFormat("ddMMyyyy_HHmm").format(new Date());
        File mediaFile;
        String mImageName="camera_wiki"+ timeStamp +".jpg";
        mediaFile = new File(mediaStorageDir.getPath() + File.separator + mImageName);
        return mediaFile;
    }

Upvotes: 1

Views: 10430

Answers (1)

AndroidEx
AndroidEx

Reputation: 15824

The issue is resolved by using a correct Date class: java.util.Date.

Upvotes: 16

Related Questions