code: private void rollOverFiles() {
  
          Context context = appContextRef.get();
  
          if (context != null) {
  
              File dir = context.getFilesDir();
  
              File mainFile = new File(dir, name(1));
  
              if (mainFile.exists()) {
  
                  float fileSize = mainFile.length();
                  fileSize = fileSize / 1024.0f; //In kilobytes
  
                  if (fileSize > fileSizeLimitKb) {
  
                      File file;
                      File target;
  
                      file = new File(dir, name(maxFiles));
                      if (file.exists()) {
                          file.delete();
                      }
  
                      for (int i = maxFiles - 1; i > 0; i--) {
                          file = new File(dir, name(i));
                          if (file.exists()) {
                              target = new File(dir, name(i + 1));
                              file.renameTo(target);
                          }
                      }
                  }
              }
          }
      }
docs: Keep the maximum size of log files close to maximum value.
  Logs are cached if the size of the currently used log file exceeds max value.