Im trying to create a file with one app, and check if it exists with another app. What im tryin to achieve is global file in cache, which can be accessed by any app on the device. I've read this: this and this one. But seems I am lost. I'm getting new file created every time I check from another app, did first app created a file.
private boolean doesFileExist() {
File file = new File(this.getCacheDir().toString() + "myfile");
if(file.exists()) {
return true;
}
else return false;
}
private void createFileForMe() {
File file = new File(this.getCacheDir().toString() + "myfile", "myfile");
file.setReadable(true, false);
Log.v("FILE", "created file");
}
public void onCreate() {
super.onCreate();
if (!doesFileExist()) {
Log.v("FILE", "FILE DOESnt EXIST");
createFileForMe();
} else Log.v("FILE", "FILE DOES EXIST");
}