• Disable cache at httpsURLConnection

    From Jakub@jak74@interia.pl to comp.mobile.android on Thu Apr 16 14:39:32 2026
    From Newsgroup: comp.mobile.android


    i have this code to sand values to server php post.
    But how to clear real cache

    try {
    val url = URL(destinationUrl)
    httpsURLConnection = url.openConnection(Proxy.NO_PROXY) as HttpsURLConnection


    httpsURLConnection.setRequestProperty("Cache-Control", "no-cache")
    httpsURLConnection.setDefaultUseCaches(false);
    httpsURLConnection.setUseCaches(false)

    saveDataString(context, "login", email)

    httpsURLConnection.requestMethod = "POST"
    httpsURLConnection.doOutput = true
    httpsURLConnection.doInput = true
    val outputStream = httpsURLConnection.outputStream

    val bufferedWriter =

    BufferedWriter(OutputStreamWriter(outputStream, "UTF-8"))
    //bufferedWriter.
    val postData =
    (
    URLEncoder.encode(
    "type",
    "UTF-8"
    ) + "=" + URLEncoder.encode(
    type, "UTF-8"
    )
    + "&"
    + URLEncoder.encode(
    "email",
    "UTF-8"
    ) + "=" + URLEncoder.encode(
    email, "UTF-8"
    )
    + "&"
    + URLEncoder.encode(
    "password",
    "UTF-8"
    ) + "=" + URLEncoder.encode(
    password, "UTF-8"
    )
    )

    Log.i("ppp", "postData ->" + postData)

    bufferedWriter.write(postData)
    bufferedWriter.flush()
    bufferedWriter.close()
    outputStream.close()

    val inputStream =
    httpsURLConnection.inputStream
    val bufferedReader =

    BufferedReader(InputStreamReader(inputStream, "UTF-8"))
    var line: String?
    while (bufferedReader.readLine().also {
    line = it } != null) {
    result += line
    }
    bufferedReader.close()
    inputStream.close()
    } catch (_: IllegalStateException) {
    showToast(
    context,

    context.resources.getString(R.string.noconnectiontointernet)
    )
    } catch (_: ProtocolException) {
    showToast(
    context,

    context.resources.getString(R.string.noconnectiontointernet)
    )
    } catch (_: UnsupportedEncodingException) {
    showToast(
    context,

    context.resources.getString(R.string.noconnectiontointernet)
    )
    } catch (_: NullPointerException) {
    showToast(
    context,

    context.resources.getString(R.string.noconnectiontointernet)
    )
    } catch (_: IOException) {
    showToast(
    context,

    context.resources.getString(R.string.noconnectiontointernet)
    )
    } finally {
    httpsURLConnection.disconnect()
    }
    }
    } else if ( params[0] == "register" ) {
    if ( params.size == 8 ) {
    try {
    val url = URL(destinationUrl)
    httpsURLConnection = url.openConnection(Proxy.NO_PROXY) as HttpsURLConnection


    httpsURLConnection.setRequestProperty("Cache-Control", "no-cache")
    httpsURLConnection.setDefaultUseCaches(false);
    httpsURLConnection.setUseCaches(false)

    /*
    val type = params[0]
    val nameFirst = params[1]
    val nameLast = params[2]
    val birthday = params[3]
    val isSexWomanRadioButton = params[4]
    val isSexManRadioButton = params[5]
    val email =
    params[6]
    val password = params[7]

    */
    httpsURLConnection.requestMethod = "POST"
    httpsURLConnection.doOutput = true
    httpsURLConnection.doInput = true

    val outputStream = httpsURLConnection.outputStream
    val bufferedWriter =

    BufferedWriter(OutputStreamWriter(outputStream, "UTF-8"))

    val postData =
    (
    URLEncoder.encode(
    "type",
    "UTF-8"
    ) + "=" + URLEncoder.encode(
    type, "UTF-8"
    )

    + "&"
    + URLEncoder.encode(
    "nameFirst",
    "UTF-8"
    ) + "=" + URLEncoder.encode(
    nameFirst, "UTF-8"
    )

    + "&"
    + URLEncoder.encode(
    "nameLast",
    "UTF-8"
    ) + "=" + URLEncoder.encode(
    nameLast, "UTF-8"
    )

    + "&"
    + URLEncoder.encode(
    "birthday",
    "UTF-8"
    ) + "=" + URLEncoder.encode(
    birthday, "UTF-8"
    )

    + "&"
    + URLEncoder.encode(
    "isSexWomanRadioButton",
    "UTF-8"
    ) + "=" + URLEncoder.encode(
    isSexWomanRadioButton, "UTF-8"
    )

    + "&"
    + URLEncoder.encode(
    "isSexManRadioButton",
    "UTF-8"
    ) + "=" + URLEncoder.encode(
    isSexManRadioButton, "UTF-8"
    )

    + "&"
    + URLEncoder.encode(
    "email",
    "UTF-8"
    ) + "=" + URLEncoder.encode(
    email, "UTF-8"
    )

    + "&"
    + URLEncoder.encode(
    "password",
    "UTF-8"
    ) + "=" + URLEncoder.encode(
    password, "UTF-8"
    )
    )

    bufferedWriter.write(postData)
    bufferedWriter.flush()
    bufferedWriter.close()
    outputStream.close()

    val inputStream =
    httpsURLConnection.inputStream
    val bufferedReader =

    BufferedReader(InputStreamReader(inputStream, "UTF-8"))
    var line: String?
    while (bufferedReader.readLine().also {
    line = it } != null) {
    result += line
    }
    bufferedReader.close()
    inputStream.close()
    } catch (_: IllegalStateException) {
    showToast(
    context,

    context.resources.getString(R.string.noconnectiontointernet)
    )
    } catch (_: ProtocolException) {
    //ZZZobject.
    showToast(
    context,

    context.resources.getString(R.string.noconnectiontointernet)
    )
    } catch (_: UnsupportedEncodingException) {
    //ZZZobject.
    showToast(
    context,

    context.resources.getString(R.string.noconnectiontointernet)
    )
    } catch (_: NullPointerException) {
    showToast(
    context,

    context.resources.getString(R.string.noconnectiontointernet)
    )
    } catch (_: IOException) {
    //ZZZobject.
    showToast(
    context,

    context.resources.getString(R.string.noconnectiontointernet)
    )
    } finally {
    httpsURLConnection.disconnect()
    }
    }
    } else
    if ( params[0] == "registerconfirm" ) {
    if ( params.size == 3 ) {
    try {
    val url = URL(destinationUrl)
    httpsURLConnection = url.openConnection(Proxy.NO_PROXY) as HttpsURLConnection


    httpsURLConnection.setRequestProperty("Cache-Control", "no-cache")

    httpsURLConnection.setDefaultUseCaches(false);
    httpsURLConnection.setUseCaches(false)

    /*
    val
    type = params[0]
    val registerEmailOrPhoneValue = params[1]
    val
    codeEnter = params[2]
    */
    httpsURLConnection.requestMethod = "POST"
    httpsURLConnection.doOutput = true
    httpsURLConnection.doInput = true
    val outputStream = httpsURLConnection.outputStream
    val bufferedWriter =

    BufferedWriter(OutputStreamWriter(outputStream, "UTF-8"))

    val postData =
    (
    URLEncoder.encode(
    "type",
    "UTF-8"
    ) + "=" + URLEncoder.encode(
    type, "UTF-8"
    )
    + "&"
    + URLEncoder.encode(

    "registerEmailOrPhoneValue",
    "UTF-8"
    ) + "=" + URLEncoder.encode(

    registerEmailOrPhoneValue, "UTF-8"
    )
    + "&"
    + URLEncoder.encode(
    "codeEnter",
    "UTF-8"
    ) + "=" + URLEncoder.encode(
    codeEnter, "UTF-8"
    )
    )

    bufferedWriter.write(postData)
    bufferedWriter.flush()
    bufferedWriter.close()
    outputStream.close()

    val inputStream = httpsURLConnection.inputStream
    val bufferedReader =

    BufferedReader(InputStreamReader(inputStream, "UTF-8"))
    var line: String?
    while (bufferedReader.readLine().also {
    line = it } != null) {
    result += line
    }
    bufferedReader.close()
    inputStream.close()
    } catch (_: IllegalStateException) {
    showToast(
    context,

    context.resources.getString(R.string.noconnectiontointernet)
    )
    } catch (_: ProtocolException) {
    //ZZZobject.
    showToast(
    context,

    context.resources.getString(R.string.noconnectiontointernet)
    )
    } catch (_: UnsupportedEncodingException) {
    //ZZZobject.
    showToast(
    context,

    context.resources.getString(R.string.noconnectiontointernet)
    )
    } catch (_: NullPointerException) {
    showToast(
    context,

    context.resources.getString(R.string.noconnectiontointernet)
    )
    } catch (_: IOException) {
    //ZZZobject.
    showToast(
    context,

    context.resources.getString(R.string.noconnectiontointernet)
    )
    } finally {
    httpsURLConnection.disconnect()
    }
    }

    --- Synchronet 3.21f-Linux NewsLink 1.2
  • From Arno Welzel@usenet@arnowelzel.de to comp.mobile.android on Thu Apr 16 16:59:33 2026
    From Newsgroup: comp.mobile.android

    Jakub, 2026-04-16 14:39:

    i have this code to sand values to server php post.
    But how to clear real cache
    [...]

    This newsgroup is about Android, not PHP.

    Also when you post code fragemtns, please remove spaces at the start of
    the lines, so they don't get wrapped.

    try {
    val url = URL(destinationUrl)
    httpsURLConnection = url.openConnection(Proxy.NO_PROXY) as HttpsURLConnection
    [...]

    And this code is not PHP but looks like JavaScript.
    --
    Arno Welzel
    https://arnowelzel.de
    --- Synchronet 3.21f-Linux NewsLink 1.2
  • From Richmond@dnomhcir@gmx.com to comp.mobile.android on Thu Apr 16 16:15:20 2026
    From Newsgroup: comp.mobile.android

    Arno Welzel <usenet@arnowelzel.de> writes:

    Jakub, 2026-04-16 14:39:

    i have this code to sand values to server php post.
    But how to clear real cache
    [...]

    This newsgroup is about Android, not PHP.

    Also when you post code fragemtns, please remove spaces at the start of
    the lines, so they don't get wrapped.

    try {
    val url = URL(destinationUrl)
    httpsURLConnection =
    url.openConnection(Proxy.NO_PROXY) as HttpsURLConnection
    [...]

    And this code is not PHP but looks like JavaScript.

    Android can run Javascript, so you've gone around in a circle.
    --- Synchronet 3.21f-Linux NewsLink 1.2
  • From =?UTF-8?Q?J=C3=B6rg_Lorenz?=@hugybear@gmx.net to comp.mobile.android on Thu Apr 16 17:51:20 2026
    From Newsgroup: comp.mobile.android

    On 16.04.26 17:15, Richmond wrote:
    Arno Welzel <usenet@arnowelzel.de> writes:

    Jakub, 2026-04-16 14:39:

    i have this code to sand values to server php post.
    But how to clear real cache
    [...]

    This newsgroup is about Android, not PHP.

    Also when you post code fragemtns, please remove spaces at the start of
    the lines, so they don't get wrapped.

    try {
    val url = URL(destinationUrl)
    httpsURLConnection =
    url.openConnection(Proxy.NO_PROXY) as HttpsURLConnection
    [...]

    And this code is not PHP but looks like JavaScript.

    Android can run Javascript, so you've gone around in a circle.

    Rather OT in any case.
    --
    "Roma locuta, causa finita" (Augustinus)
    --- Synchronet 3.21f-Linux NewsLink 1.2
  • From Arno Welzel@usenet@arnowelzel.de to comp.mobile.android on Thu Apr 16 20:56:19 2026
    From Newsgroup: comp.mobile.android

    Richmond, 2026-04-16 17:15:

    Arno Welzel <usenet@arnowelzel.de> writes:

    Jakub, 2026-04-16 14:39:

    i have this code to sand values to server php post.
    But how to clear real cache
    [...]

    This newsgroup is about Android, not PHP.

    Also when you post code fragemtns, please remove spaces at the start of
    the lines, so they don't get wrapped.

    try {
    val url = URL(destinationUrl)
    httpsURLConnection =
    url.openConnection(Proxy.NO_PROXY) as HttpsURLConnection
    [...]

    And this code is not PHP but looks like JavaScript.

    Android can run Javascript, so you've gone around in a circle.

    How to "run JavaScript" in Android itself and not using a web browser?
    --
    Arno Welzel
    https://arnowelzel.de
    --- Synchronet 3.21f-Linux NewsLink 1.2
  • From Andy Burns@usenet@andyburns.uk to comp.mobile.android on Fri Apr 17 07:44:46 2026
    From Newsgroup: comp.mobile.android

    Arno Welzel wrote:

    Jakub wrote:

    try {
    val url = URL(destinationUrl)
    httpsURLConnection =
    url.openConnection(Proxy.NO_PROXY) as HttpsURLConnection
    [...]

    And this code is not PHP but looks like JavaScript.
    From the "as" keyword, it looks like Kotlin ...

    --- Synchronet 3.21f-Linux NewsLink 1.2
  • From Arno Welzel@usenet@arnowelzel.de to comp.mobile.android on Fri Apr 17 12:06:21 2026
    From Newsgroup: comp.mobile.android

    Andy Burns, 2026-04-17 08:44:

    Arno Welzel wrote:

    Jakub wrote:

    try {
    val url = URL(destinationUrl)
    httpsURLConnection =
    url.openConnection(Proxy.NO_PROXY) as HttpsURLConnection
    [...]

    And this code is not PHP but looks like JavaScript.
    From the "as" keyword, it looks like Kotlin ...

    Yes, you're right. Seems to be Kotlin and thus more on-topic here again.
    --
    Arno Welzel
    https://arnowelzel.de
    --- Synchronet 3.21f-Linux NewsLink 1.2
  • From Andy Burns@usenet@andyburns.uk to comp.mobile.android on Fri Apr 17 11:11:28 2026
    From Newsgroup: comp.mobile.android

    Arno Welzel wrote:

    Andy Burns wrote:

    Arno Welzel wrote:

    Jakub wrote:

    try {
    val url = URL(destinationUrl)
    httpsURLConnection =
    url.openConnection(Proxy.NO_PROXY) as HttpsURLConnection
    [...]

    And this code is not PHP but looks like JavaScript.
    From the "as" keyword, it looks like Kotlin ...

    Yes, you're right. Seems to be Kotlin and thus more on-topic here again.
    Unfortunately Jakub has a habit of drive-by questions with no follow up, that's quite a long example to expect someone to grok and respond to ...


    --- Synchronet 3.21f-Linux NewsLink 1.2