如何在另一个类中调用此方法?从另一个类调用arraylist方法
我需要使用这个方法内的数组列表从一个名为数据库帮助器的类中将一个变量的值与另一个类(主菜单)中的这个数组列表进行比较。
的想法是,它会在数据库内的所有值和 检查是否从类主菜单中值的变量是类数据库辅助的数组列表内的任何地方。
public ArrayList<Phone> retrieveAllPhones() {
ArrayList<Phone> phoneArrayList
= new ArrayList<>();
// SELECT * FROM student;
SQLiteDatabase db = getReadableDatabase();
Cursor cursor = db.query(Phone.TABLE,
null,// columns
null,// selection
null,// selection args
null,// group by
null,// having
null// order by
);
if (cursor.moveToFirst()) {
do {
Phone phone = new Phone();
phone.setSenderNum(
cursor.getString(cursor.getColumnIndex(Phone.NUM))
);
// assign this name to Student
phone.setMessage(
cursor.getString(cursor.getColumnIndex(Phone.MESSAGE))
);
phone.setGeo(
cursor.getString(cursor.getColumnIndex(Phone.GEO))
);
phoneArrayList.add(phone);
} while (cursor.moveToNext());
}