Something I did when I first installed the application was to make a script to parse the FoxClocks configuration file* and convert each clock into a SQL statement to then insert them into the app database (since adding the clocks manually was going to be very time consuming).
The problem with this is that it's impractical since it requires having a rooted phone, so it could be very useful to have an option to import the FoxClocks clocks directly into the app.
For what it's worth, the parser could be done with this code (adapted version of the Python script I originally made):
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class FoxclocksDataParser {
private static final Pattern extractor = Pattern.compile(
"id=\"([^\"]+)\"/>(?:<Name>([^<]+)</Name>)?<Coordinates latitude=\"([^\"]+)\" longitude=\"([^\"]+)\"|<Location><Zone id=\"([^\"]+)\"/></Location>"
);
public static void dataParser(String data) {
Matcher matcher = extractor.matcher(data);
while (matcher.find()) {
String timezoneId = matcher.group(1);
String name = matcher.group(2) == null ? "" : matcher.group(2);
String latitude = matcher.group(3);
String longitude = matcher.group(4);
String city = "";
if (timezoneId != null) {
String[] parts = timezoneId.split("/");
if (parts.length > 1) {
city = parts[1].replace("_", " ");
}
}
// UTC is a special case
if (matcher.group(0).indexOf("Etc/UTC") > -1) {
timezoneId = "GMT";
city = "UTC";
name = "Coordinated Universal Time";
latitude = longitude = "0.0";
}
System.out.printf(
"insert into clocks (time_diff, timezone_id, city, area, latitude, longitude) " +
"values (0, '%s', '%s', '%s', '%s', '%s');%n",
timezoneId, city, name, latitude, longitude
);
}
}
public static void main(String[] args) {
// Use example
if (args.length >= 1) {
BufferedReader objReader = null;
try {
String strCurrentLine;
objReader = new BufferedReader(new FileReader(args[0]));
StringBuilder stringBuilder = new StringBuilder();
while ((strCurrentLine = objReader.readLine()) != null) {
stringBuilder.append(strCurrentLine);
stringBuilder.append("\n");
}
dataParser(stringBuilder.toString());
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (objReader != null) { objReader.close(); }
}
catch (IOException ex) { ex.printStackTrace(); }
}
}
else { System.out.println("A file is needed to parse. Exiting"); }
}
}
To test it just save it as FoxclocksDataParser.java and run the following:
javac FoxclocksDataParser.java
java FoxclocksDataParser /path/to/the/foxclocks/config
Which returns an insert statement for each clock found. When inserting that in /data/data/ch.corten.aha.worldclock/databases/worldclock, the result is the following after restarting the application:

I also take the opportunity to leave the configuration file* with which I did this and to be able to test the example code.
- The file is from an old/legacy version of FoxClocks, since when they migrated it to WebExtensions the option to import/export the configuration disappeared or was never integrated (at least in the Firefox extension, but it is possible that it is the same in other browsers).
Something I did when I first installed the application was to make a script to parse the FoxClocks configuration file* and convert each clock into a SQL statement to then insert them into the app database (since adding the clocks manually was going to be very time consuming).
The problem with this is that it's impractical since it requires having a rooted phone, so it could be very useful to have an option to import the FoxClocks clocks directly into the app.
For what it's worth, the parser could be done with this code (adapted version of the Python script I originally made):
To test it just save it as FoxclocksDataParser.java and run the following:
Which returns an insert statement for each clock found. When inserting that in /data/data/ch.corten.aha.worldclock/databases/worldclock, the result is the following after restarting the application:

I also take the opportunity to leave the configuration file* with which I did this and to be able to test the example code.