从同一个 TextView 中保存两个整数

Saving Two Integers From The Same TextView

我创建了一个由小时、分钟和秒组成的秒表。理想情况下,我希望用户在希望停止秒表时单击按钮,从而节省时间的价值。我需要存储这个整数。

下次用户执行此操作时,将再次存储 int,而不是覆盖之前存储的现有 int,因为我需要两个整数。所以现在应该有两个整数,存储在数据库或类似 SharedPrefences 的东西中。

考虑到它来自同一个 TextView,这将如何实现?

谢谢

为什么不使用 ArrayList,每次获取这些整数时,将它们存储在 ArrayList 中,然后可以检索它们以将任何位置存储为元素 0 和 1。

    ArrayList<Integer> integerArrayList= new ArrayList<>();
    //calling this below each time hitting the button
    int theInt=Integer.parseInt(txt.getText().toString());
    integerArrayList.add(theInt);