Question: I want to change the selected color of all my `UITableViewCell`s. I am already using `UIAppearence` to define basic properties for some other UI elements and it works.

However, setting

```
let bgColorView = UIView()
bgColorView.backgroundColor = #colorLiteral(red: 0.9411764706, green: 0.9411764706, blue: 0.9411764706, alpha: 1)
UITableViewCell.appearance().selectedBackgroundView = bgColorView

```

Results in a strange glitch, the cell losing the selection color, although the `UITableViewCell`s is still selected:

[![UITableViewCell disappearing selection](https://i.stack.imgur.com/Pm6QF.gif)](https://i.stack.imgur.com/Pm6QF.gif)

The glitch is not caused by UI code because setting the selected color directly in `UITableViewCell.awakeFromNib` works fine, the selected cell stays the desired color.

**Edit**: This happens with all the different cells. The cells do not do anything interesting, just set stuff like label colors, etc in `awakeFromNib` and some `RxSwift` binding in a model setter to set the values of the various labels. The VCs just react to the cell getting selected by calling a delegate method (using `modelSelected` from `RxSwift`).

**Edit**: The VC with the `UITableView` is the "left side" of a `UISplitViewController`. The "right side" is a `UINavigationController` and navigation in this `UINavigationController` using `setViewControllers` after tapping the cell causes the strange glitch.

Answer: 
After some more searching I found that I'm using the incorrect location to save my log files. To solve the issue I had to make the following changes to the `logback.xml` configuration:

```
<configuration>

    <property name="LOGFILE_NAME" value="log.txt" />
    <property name="EXT_FILES_DIR" value="${EXT_DIR:-/sdcard}/Android/data/${PACKAGE_NAME}/files" />

    <appender name="rollingfile" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${EXT_FILES_DIR}/${LOGFILE_NAME}</file>

        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <fileNamePattern>${LOGFILE_NAME}.%i</fileNamePattern>
            <minIndex>1</minIndex>
            <maxIndex>1</maxIndex>
        </rollingPolicy>

        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <maxFileSize>400KB</maxFileSize>
        </triggeringPolicy>

        <encoder>
            <pattern>%date %-5level %logger{10} - %msg%n</pattern>
        </encoder>
    </appender>

    <root level="TRACE">
        <appender-ref ref="rollingfile" />
    </root>

</configuration>

```

The relevant change is the value of property `EXT_FILES_DIR`. This will now use the external storage available to the application instead of the old path `/data/data/nl.charm.nedradio/files`.

The other change needed is in the `file_provider_paths.xml`. Here the external path is changed from `"."` to `"/"`:

```
<?xml version="1.0" encoding="utf-8"?>
<paths>
    <external-files-path name="files" path="/" />
</paths>

```

Now sharing works with e.g. Gmail and Google Drive.
Here is a similar question,thers is a [picture](https://i.stack.imgur.com/RYRJb.png) which is in my answer.please check [this question](https://stackoverflow.com/questions/37074872/android-fileprovider-on-custom-external-storage-folder/52826761#52826761) and I promise that can fix your problem.

```
<files-path name="name" path="path" />  
Represents files in the files/ subdirectory of your app's internal storage area. This subdirectory is the same as the value returned by Context.getFilesDir().

<external-path name="name" path="path" />
Represents files in the root of the external storage area. The root path of this subdirectory is the same as the value returned by Environment.getExternalStorageDirectory().

<external-files-path name="name" path="path" />
Represents files in the root of your app's external storage area. The root path of this subdirectory is the same as the value returned by Context#getExternalFilesDir(String) Context.getExternalFilesDir(null).

```