What is the best way to create temporary files on Android?

前端 未结 3 654
南旧
南旧 2020-12-09 19:25

Well, this is not exactly a question, as I\'m not really \"stuck\" on my code, but I\'ve found some strange behavior for Android API regarding accessing the external storage

3条回答
  •  甜味超标
    2020-12-09 19:35

    try like this...

    File outputDir = context.getCacheDir(); // context being the Activity pointer
    File outputFile = File.createTempFile("prefix", "extension", outputDir);
    

    Edit :

    for Question 2

    It may be issue as below link...

    Environment.getExternalStorageDirectory does not return the path to the removable storage

提交回复
热议问题