Skip to content

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented May 1, 2025

Add new method Ti.App.Android.clearUserCache() to clear the user data and app cache. It's basically the same as going into the app info menu - cache - clear data. It will close the app.

var win = Titanium.UI.createWindow({});
win.open();
var btn = Ti.UI.createButton({title:"clear"})
win.add(btn);
btn.addEventListener("click", function(){
	console.log(Ti.App.Android.clearUserCache());
})

Copy link
Contributor

@prashantsaini1 prashantsaini1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will perform the Clear Data action rather than the Clear Cache. Curious to know when someone would want to do this with their app?

@m1ga
Copy link
Contributor Author

m1ga commented May 15, 2025

Correct. As mentioned in the docs Clears app data and cache so the whole app will be reset. It might be useful if you have user data that you want to clear completely and want to start with a fresh app. I've used it a lot on apps during debugging. Having it in the app would speed up that process

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants