- logFile.createNewFile();
- buf = new BufferedWriter(new FileWriter(logFile, true));
- isEnabled = true;
- appendPhoneInfo();
- }catch (IOException e){
+
+ if (isMaxFileSizeReached) {
+
+ // Move current log file info to another file (old logs)
+ File olderFile = new File(mFolder + File.separator + mLogFileNames[1]);
+ if (mLogFile.exists()) {
+ mLogFile.renameTo(olderFile);
+ }
+
+ // Construct a new file for current log info
+ mLogFile = new File(mFolder + File.separator + mLogFileNames[0]);
+ isMaxFileSizeReached = false;
+ }
+
+ // Create the current log file if does not exist
+ mLogFile.createNewFile();
+ mBuf = new BufferedWriter(new FileWriter(mLogFile, true));
+ if (isFileCreated) {
+ appendPhoneInfo();
+ }
+
+ // Check if current log file size is bigger than the max file size defined
+ if (mLogFile.length() > MAX_FILE_SIZE) {
+ isMaxFileSizeReached = true;
+ }
+ } catch (IOException e) {