How to create private folder in sdcard

前端 未结 5 1904
名媛妹妹
名媛妹妹 2021-02-05 16:05

My application is used for security purpose. so, from my application user captures photos that all photos are stored in a folder that folder should not access from any other app

5条回答
  •  死守一世寂寞
    2021-02-05 16:56

    According to this guide, you can save files directly on the device's internal storage. By default, files saved to the internal storage are private to your application and other applications cannot access them (nor can the user). When the user uninstalls your application, these files are removed. For example:

    String FILENAME = "hello_file";
    String string = "hello world!";
    FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
    fos.write(string.getBytes());
    fos.close();
    

    MODE_PRIVATE will create the file (or replace a file of the same name) and make it private to your application. Other modes available are: MODE_APPEND, MODE_WORLD_READABLE, and MODE_WORLD_WRITEABLE.

提交回复
热议问题