Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Java
//// ERROR
warning: [deprecation] getExternalStorageDirectory() in Environment has been deprecated
 File path = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/MyPaintings");
                                    ^
1 warning




   //// That my cood

 private static String fileName;
    File path = new File(Environment.getExternalStorageDirectory().getAbsolutePath() +"/MyPaintings");

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        signatureView = findViewById(R.id.signature_view);
        seekBar = findViewById(R.id.penSize);
        txtPenSize = findViewById(R.id.txtPenSize);
        imgColor = findViewById(R.id.btnColor);
        imgEraser = findViewById(R.id.btnEraser);
        imgSave = findViewById(R.id.btnSave);

        askPermission();

        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault());
        String date = format.format(new Date());
        fileName = path + "/" + date  +  ".png";

        if (!path.exists())
        {
            path.mkdirs();
        }

        defaultColor = ContextCompat.getColor(MainActivity.this, R.color.black);


What I have tried:

Quote:
How can I write this code correctly? And thank you for help
Posted
Updated 12-Aug-22 22:27pm

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900