Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在开发一个 Android 应用程序。当我按下按钮时,我需要以编程方式清除数据,包括数据存储首选项和房间数据。
要清除共享偏好:
SharedPreferences settings = getActivity().getSharedPreferences("cda-preferences", Context.MODE_PRIVATE); settings.edit().clear().commit();
并使用数据库的删除查询:)