class RuleDatabaseItemUpdateRunnable implements Runnable {

    @Override
    public void run() {
        try {
            android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND);
        } catch (UnsatisfiedLinkError e) {
        } catch (RuntimeException e) {
            if (!e.toString().contains("not mocked"))
                throw e;
        }

        if (item.location.startsWith("content:/")) {
            try {
                Uri uri = parseUri(item.location);
                context.getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);

                context.getContentResolver().openInputStream(uri).close();
                Log.d(TAG, "run: Permission requested for " + item.location);
            } catch (SecurityException e) {
                Log.d(TAG, "doInBackground: Error taking permission: ", e);
                parentTask.addError(item, context.getString(R.string.permission_denied));
            } catch (FileNotFoundException e) {
                parentTask.addError(item, context.getString(R.string.file_not_found));
            } catch (IOException e) {
                parentTask.addError(item, context.getString(R.string.unknown_error_s, e.getLocalizedMessage()));
            }
            return;
        }

        SingleWriterMultipleReaderFile singleWriterMultipleReaderFile = new SingleWriterMultipleReaderFile(file);
        HttpURLConnection connection = null;
        parentTask.addBegin(item);
        try {
            connection = getHttpURLConnection(file, singleWriterMultipleReaderFile, url);

            if (!validateResponse(connection))
                return;
            downloadFile(file, singleWriterMultipleReaderFile, connection);
        } catch (SocketTimeoutException e) {
            parentTask.addError(item, context.getString(R.string.requested_timed_out));
        }catch (IOException e) {
            parentTask.addError(item, context.getString(R.string.unknown_error_s, e.toString()));
        } finally {
            parentTask.addDone(item);
            if (connection != null)
                connection.disconnect();
        }
    }

      RuleDatabaseItemUpdateRunnable(@NonNull RuleDatabaseUpdateTask parentTask, @NonNull Context context, @NonNull Configuration.Item item);

}