如何清除数据的编程机器人机器人、数据

2023-09-07 01:33:25 作者:言衷善

我开发一个Android应用程序。我需要清除编程包括preferences,当我preSS一个按钮,数据库中的数据。

I am developing an Android App. I need to clear the data programmatically including the preferences and databases when i press a button.

推荐答案

要清除共享prefrences:

To clear the Shared Prefrences :

SharedPreferences settings = getActivity().getSharedPreferences("cda-preferences", Context.MODE_PRIVATE); 
        settings.edit().clear().commit();

和使用删除查询数据库:)

and use the delete query for the database :)