-1
我想制作一个应用程序,它可以计算我在一天中访问应用程序的时间,并且每天应该重置共享偏好。即它应该每天从0开始自动计数。我如何使用共享首选项来执行此操作。以下是代码:我想统计每天打开应用程序的次数
prefs = getPreferences(Context.MODE_PRIVATE);
editor = prefs.edit();
// editor.clear();
totalCount = prefs.getInt("counter", 0);
totalCount++;
editor.putInt("counter", totalCount);
editor.commit();
Toast.makeText(getApplicationContext(),"Hello User..!! You have entered the App " +totalCount+ " time today",Toast.LENGTH_LONG).show();
而不是存储为**计数器**,可以使用作为**“[某种格式的日期] - 计数器”**在这你可以得到每一天 –
我该怎么做。你可以告诉吗? @MuthukrishnanRajendran – Abhi