android - storing image cache in internal memory and reusing it

前端 未结 1 1275
無奈伤痛
無奈伤痛 2021-01-07 11:47

in my app i am trying to store the images in internal memory so that it can be used only in my app and cannot be seen in other ways.

In the following way i have stor

相关标签:
1条回答
  • 2021-01-07 12:39

    You have written wrong code.

    Replace

    File cacheDir = getApplicationContext().getDir("", Context.MODE_PRIVATE); 
    File fileWithinMyDir = new File(cacheDir, "");
    

    To

    File fileWithinMyDir = getApplicationContext().getFilesDir();
    

    Then

    Replace

    String PATH =  fileWithinMyDir + filename;
    

    To

    String PATH =  fileWithinMyDir.getAbsolutePath() + "/" +filename+".file extension";
    
    0 讨论(0)
提交回复
热议问题