How to Clear Data of my app ?

pluton

Active Member
Licensed User
Longtime User
Is it possible to make clear data in my app without manually going Settings -> Applications -> manage applications ->myapp -> Clear Data ??

Reason why I asking this is because I have facebook aplication and I want to user logout from app when it doesn't need it.
Facebook changed policy of logout so now it is not working facebook.com/logout.php

Can I just call some function example Clear cache or some cookies from my webview. I don't know :sign0013:

Does anyone has this problem also :BangHead:
 

admac231

Active Member
Licensed User
Longtime User
When I asked about clearing the webview cache logging out of facebook was exactly what I was trying to do. Unfortunately clearing the cache doesn't always work so I ended up using a rather side-stepped method for logging out.

Use the JSInterface library to programmatically press the "Logout" button on Facebook.

I don't have the code to hand but I will post it when I do.
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Maybe it's not just the WebView's cached files you need to clear but also any cookies?

The documentation for the native WebView clearCache method simply states:

clearCache(boolean includeDiskFiles)
Clear the resource cache.

It doesn't mention whether cookies are also cleared - i'd imagine a session cookie to be used by Facebook when you're logged in.
If that cookie isn't cleared the user would probably remain logged in.

Martin.
 
Upvote 0

admac231

Active Member
Licensed User
Longtime User
Okay, well as I said it's a bit hashy but it works :)

B4X:
'Initialise the JSInterface
Dim jsi As JSInterface
jsi.addJSInterface(Webview1,"B4A")

'Load facebook.com/terms.php
WebView1.LoadUrl("http://www.facebook.com/terms.php")

'When the page has finished loading press the logout button
Sub WebView1_PageFinished (Url As String)
   If url.IndexOf("terms.php") >-1 Then
      ProgressDialogShow("Logging out...")
      jsi.execJS(WebView1,"document.forms['logout_form'].submit();")
   Else If url.IndexOf("refsrc=http%3A%2F%2Fwww.facebook.com%2Fterms.php&_rdr") >-1 Then 
      ProgressDialogHide
      Log("Logged Out")   
   End If
End Sub
 
Upvote 0
Top