Skip to content

Commit 405c51a

Browse files
authored
feat(android): clearUserCache method (#14213)
* feat(android): clearUserCache method * Update apidoc/Titanium/App/Android/Android.yml
1 parent e47e4b2 commit 405c51a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

android/modules/app/src/java/ti/modules/titanium/app/AndroidModule.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
*/
77
package ti.modules.titanium.app;
88

9+
import static android.content.Context.ACTIVITY_SERVICE;
10+
911
import org.appcelerator.kroll.KrollModule;
1012
import org.appcelerator.kroll.KrollRuntime;
1113
import org.appcelerator.kroll.annotations.Kroll;
@@ -17,6 +19,7 @@
1719
import org.appcelerator.titanium.proxy.RProxy;
1820

1921
import android.app.Activity;
22+
import android.app.ActivityManager;
2023
import android.content.Intent;
2124
import android.content.pm.PackageInfo;
2225
import android.content.pm.PackageManager.NameNotFoundException;
@@ -61,6 +64,13 @@ public ActivityProxy getTopActivity()
6164
}
6265
}
6366

67+
@Kroll.method
68+
public Boolean clearUserCache()
69+
{
70+
return ((ActivityManager) TiApplication.getInstance()
71+
.getSystemService(ACTIVITY_SERVICE)).clearApplicationUserData();
72+
}
73+
6474
@Kroll.getProperty
6575
public int getAppVersionCode()
6676
{

apidoc/Titanium/App/Android/Android.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ properties:
6464
permission: read-only
6565
since: 3.3.0
6666

67+
methods:
68+
- name: clearUserCache
69+
summary: Clears app data and cache. This will close the app.
70+
since: 13.1.0
71+
6772
events:
6873
- name: shortcutitemclick
6974
summary: Fired when a <Titanium.UI.ShortcutItem> is clicked.

0 commit comments

Comments
 (0)