Back to project page digitalcampus.
The source code is released under:
MIT License
If you think the Android project digitalcampus listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.llenguatges.digitalcampus; /*w w w .j a v a2s . c om*/ import java.io.IOException; import java.util.ArrayList; import java.util.List; import android.app.Application; import com.llenguatges.digitalcampus.database.DAOHelper; import com.llenguatges.digitalcampus.database.StudentTable; import com.llenguatges.digitalcampus.database.SubjectTable; import com.llenguatges.digitalcampus.objects.Student; import com.llenguatges.digitalcampus.objects.Subject; public class MyApplication extends Application { private DAOHelper helper; private List<Subject> subjectList; private SubjectTable st; private List<Student> studentList; private StudentTable stt; /** * Called when the activity is first created. * This is where you all of static set up: customize ActionBar. * This method also provides you with a Bundle containing the * activity's previously frozen state, if there was one. */ public void onCreate(){ super.onCreate(); helper = new DAOHelper(getApplicationContext()); if(!helper.checkDataBase()){ try { helper.copyDataBase(); } catch (IOException e) { e.printStackTrace(); } } startSubjectTable(); startStudentTable(); } /** * Initialize student's table */ private void startStudentTable() { studentList = new ArrayList<Student>(); stt = new StudentTable(getApplicationContext()); studentList = stt.GetDataFromTable(); } /** * Initialize subject's table */ public void startSubjectTable() { subjectList = new ArrayList<Subject>(); st = new SubjectTable(getApplicationContext()); subjectList = st.GetDataFromTable(); } /** * Get subject's list * @return subjectList */ public List<Subject> getSubjects(){ return subjectList; } /** * Get student's list * @return subjectList */ public List<Student> getStudent(){ return studentList; } /** * Delete subject from list by position * @param pos */ public void removeSubject(int pos){ subjectList.remove(pos); } /** * Delete student from list by position * @param pos */ public void removeStudent(int pos){ studentList.remove(pos); } /** * Add subject to list * @param sub */ public void setSubjects(List<Subject> sub){ subjectList = sub; } /** * Add student to list * @param stu */ public void setStudents(List<Student> stu){ studentList = stu; } /** * Add subject to list * @param sub */ public void addSubject(Subject sub){ subjectList.add(sub); } /** * Add student to list * @param sub */ public void addStudent(Student stu){ studentList.add(stu); } }