@staticmethod
def get_files_dir():
    """
        Alternative App._get_user_data_dir() implementation for Android
        that also works when within a service activity.
        """
    from jnius import autoclass, cast
    PythonActivity = autoclass('org.kivy.android.PythonActivity')
    activity = PythonActivity.mActivity
    if activity is None:
        PythonService = autoclass('org.kivy.android.PythonService')
        activity = PythonService.mService
    context = cast('android.content.Context', activity)
    file_p = cast('java.io.File', context.getFilesDir())
    data_dir = file_p.getAbsolutePath()
    return data_dir
