You are missing a bracket there in if statement
Gdx.files.local("/files/ids.json").exists())
I wonder how that code got compiled in the first place
If you just missed it while writing the post, then make sure that file is not used somewhere else when you are trying to delete it.
There is that scenario when delete() method returns false:
the delete method looks like this:
public boolean delete () {
if (type == FileType.Classpath) throw new GdxRuntimeException("Cannot delete a classpath file: " + file);
if (type == FileType.Internal) throw new GdxRuntimeException("Cannot delete an internal file: " + file);
return file().delete();
}
and the delete from file.delete() looks like this :
public boolean delete() {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkDelete(path);
}
if (isInvalid()) {
return false;
}
return fs.delete(this);
}
You can notice the isInvalid() method which is checking for a NULL character in the path (basicly checks if the the path is invalid) :
/**
* Check if the file has an invalid path. Currently, the inspection of
* a file path is very limited, and it only covers Nul character check.
* Returning true means the path is definitely invalid/garbage. But
* returning false does not guarantee that the path is valid.
*
* @return true if the file path is invalid.
*/
final boolean isInvalid() {
if (status == null) {
status = (this.path.indexOf('\u0000') < 0) ? PathStatus.CHECKED
: PathStatus.INVALID;
}
return status == PathStatus.INVALID;
}
Im mentioning that because i have been in situations when i used strings that contained weird unicode chars in it and even thou I couldn't see it normally it was there and IntelliJ was the root cause (what came out much later). Make sure that the path you specified is correct, try to invalidate the files, clean and rebuild the project.