如何在android中检测重复的字符串?

时间:2017-03-25 13:39:43

标签: android string

每次按下按钮,我的代码都会保存编辑文本中的字符串。但是,如果我再次输入相同的字符串,它会保存它。如果之前已保存,如何防止保存?

HistoryHelper file = new HistoryHelper(getBaseContext());
                // get date
                Calendar c = Calendar.getInstance();
                int date = c.get(Calendar.DATE);
                int month = c.get(Calendar.MONTH) + 1;// fixes wrong month
                int year = c.get(Calendar.YEAR);
                file.writeToSD("Date: " + year + "-" + month + "-" + date);
                // get string
                file.writeToSD(NEWLINK.toString());
                // leave a blank line space
                file.writeToSD("".toString());

0 个答案:

没有答案