내 응용 프로그램에서 날짜를 포함하는 공유 prefernces를 사용하여 2 차원 배열을 저장하고 있습니다. 배열 날짜를 현재 날짜와 일치시켜야합니다. 모든 것은 공개 공백입니다 onrecieve()
를 저장하는 때 현재 날짜와 공유 환경 설정에 저장된 문자열을 일치시키는 방법
String[][] my_date;
Set<String> checkDate;
/* getting today date and coverting it into string */
Calendar cal=Calendar.getInstance();
int todaysDate = cal.get(Calendar.DAY_OF_MONTH);
String cDate = Integer.toString(todaysDate);
SharedPreferences pref = arg0.getSharedPreferences("MyPref", 0); // 0 - for private mode
SharedPreferences.Editor editor = pref.edit();
Set<String> set = new HashSet<String>();
for(int i = 0; i < my_date.length; i++){
for(int j = 0; j < my_date[i].length; j++){
set.add("'" + my_date[i][j] + "'");
Log.v("dates", my_date[i][j]);
}
}
editor.putStringSet("dates", set);
editor.commit();
checkDate = pref.getStringSet("dates", set);
if(checkDate.contains(cDate)){
Intent mIntent = new Intent(arg0,DialogActivity.class);
mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
arg0.startActivity(mIntent);
}
무엇합니까 로그인'cDate'와'my_date [I] [J]'인쇄? – Simulant