0

I wish to create a file on my device somewhere (I don't mind where or what the file contains, my only concern is the name of the file), then have my app look for the existence of that file. The idea is to have a mechanism to secretly unlock some features of my app to anyone I tell about the file.

My only problem is that I have never written any code to read/write files outside of my own app's space before, so I'm not sure how to do it. Can someone give me some pointers.

4

1 回答 1

1

您可以使用 File.exists() 方法来确定文件是否存在。

  File testfile = new File(Environment.getExternalStorageDirectory()
                + File.separator ,
                "myfile");
        if (testfile.exists()) {
            //file exists. enable your features
        }
于 2012-11-14T14:54:55.000 回答