Question

Create a Student Planner app that will allow students to keep track of homework due dates...

Create a Student Planner app that will allow students to keep track of homework due dates for the classes they are currently taking. The first app activity (screen) will display the list of classes the student has entered. There should also be a way for students to add, edit, and remove classes from the list. When students select a class they should be taken to a second activity (screen) which will display the assignment name and due date (at minimum, though you may add additional information fields if desired) for all assignments for the selected class. Students should also have the option to add, edit, and remove assignments from the list. You must use an SQLite database with for this assignment. You should have at least 2 tables in your database. One table for class information and another table for assignment information. You may use the method of your choice to display the information and to enable students to modify the lists in each activity

0 0
Add a comment Improve this question Transcribed image text
Answer #0

sqlite database is used to store data through different tables.

import android.app.Activity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import android.widget.Toast;
public class databaseHandler {
SQLiteDatabase database;
Activity activity;
public databaseHandler(Activity activity) {
this.activity = activity;
database = activity.openOrCreateDatabase("ASSIST", activity.MODE_PRIVATE, null);
createTable();
}
public void createTable()
{
try {
String qu = "CREATE TABLE IF NOT EXISTS STUDENT(name varchar(1000)," +
"cl varchar(100), " +
"regno varchar(100) primary key, contact varchar(100),roll integer);";
database.execSQL(qu);
}catch (Exception e)
{
Toast.makeText(activity,"Error Occured for create table",Toast.LENGTH_LONG).show();
}
try {
String qu = "CREATE TABLE IF NOT EXISTS ATTENDANCE(datex date," +
"hour int, " +
"register varchar(100) ,isPresent boolean);";
database.execSQL(qu);
}catch (Exception e)
{
Toast.makeText(activity,"Error Occured for create table",Toast.LENGTH_LONG).show();
}
try {
String qu = "CREATE TABLE IF NOT EXISTS NOTES(title varchar(100) not null," +
"body varchar(10000), cls varchar(1000), sub varchar(1000) ,datex TIMESTAMP default CURRENT_TIMESTAMP);";
database.execSQL(qu);
}catch (Exception e)
{
Toast.makeText(activity,"Error Occured for create table",Toast.LENGTH_LONG).show();
}
try {
String qu = "CREATE TABLE IF NOT EXISTS SCHEDULE(cl varchar(100),subject varchar(1000)," +
"timex time, day_week varchar(100));";
database.execSQL(qu);
}catch (Exception e)
{
Toast.makeText(activity,"Error Occured for create table",Toast.LENGTH_LONG).show();
}
}
public boolean execAction(String qu)
{
Log.i("databaseHandler", qu);
try {
database.execSQL(qu);
}catch (Exception e)
{
Log.e("databaseHandler", qu);
Toast.makeText(activity,"Error Occured for execAction",Toast.LENGTH_LONG).show();
return false;
}
return true;
}
Cursor execQuery(String qu)
{
try {
return database.rawQuery(qu,null);
}catch (Exception e)
{
Log.e("databaseHandler", qu);
Toast.makeText(activity,"Error Occured for execAction",Toast.LENGTH_LONG).show();
}
return null;
}
}

Main Activity

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
>
<GridView
android:layout_width="match_parent"
android:numColumns="2"
android:id="@+id/grid"
android:background="#e7e7e7"
android:columnWidth="150dp"
android:gravity="center"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:stretchMode="columnWidth"
android:layout_height="match_parent">
</GridView>
</ LinearLayout >

BaseActivity.java

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.GridView;
import java.util.ArrayList;

public class AppBase extends AppCompatActivity {
private ArrayList<String> basicFields;
private gridAdapter adapter;
public static ArrayList<String> divisions ;
private GridView gridView;
public static databaseHandler handler;
public static Activity activity;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.mai_menu, menu);
return true;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.base_layout);
basicFields = new ArrayList<>();
handler = new databaseHandler(this);
activity = this;
getSupportActionBar().show();
divisions = new ArrayList();
divisions.add("S1 COMPUTER SCIENCE");
divisions.add("S2 COMPUTER SCIENCE");
divisions.add("S3 COMPUTER SCIENCE");
divisions.add("S4 COMPUTER SCIENCE");
divisions.add("S5 COMPUTER SCIENCE");
divisions.add("S6 COMPUTER SCIENCE");
divisions.add("S7 COMPUTER SCIENCE");
gridView = (GridView)findViewById(R.id.grid);
basicFields.add("ATTENDANCE");
basicFields.add("SCHEDULER");
basicFields.add("NOTES");
basicFields.add("PROFILE");
basicFields.add("CGPA CALCULATOR");
adapter = new gridAdapter(this,basicFields);
gridView.setAdapter(adapter);
}
public void loadSettings(MenuItem item) {
Intent launchIntent = new Intent(this,SettingsActivity.class);
startActivity(launchIntent);
}
public void loadAbout(MenuItem item) {
Intent launchIntent = new Intent(this,About.class);
startActivity(launchIntent);
}
}

Custom Grid Adapter

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.FragmentManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.ScaleAnimation;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class GridAdapter extends BaseAdapter{
private ArrayList<String> names;
public static Activity activity;
public gridAdapter(Activity activity, ArrayList names) {
this.activity = activity;
this.names = names;
}
@Override
public int getCount() {
return names.size();
}
@Override
public Object getItem(int position) {
return names.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View v, ViewGroup parent) {
if (v == null) {
LayoutInflater vi = LayoutInflater.from(activity);
v = vi.inflate(R.layout.grid_layout, null);
}
TextView textView = (TextView)v.findViewById(R.id.namePlacer);
ImageView imageView = (ImageView)v.findViewById(R.id.imageHolder);
if(names.get(position).toString().equals("ATTENDANCE"))
{
imageView.setImageResource(R.drawable.ic_attendance);
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentManager fm = activity.getFragmentManager();
createRequest request = new createRequest();
request.show(fm,"Select");
}
});
}else if(names.get(position).toString().equals("SCHEDULER"))
{
imageView.setImageResource(R.drawable.ic_schedule);
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent launchinIntent = new Intent(activity, scheduler.class);
activity.startActivity(launchinIntent);
}
});
}else if(names.get(position).toString().equals("NOTES"))
{
imageView.setImageResource(R.drawable.ic_notes);
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent launchinIntent = new Intent(activity, noteActivity.class);
activity.startActivity(launchinIntent);
}
});
}else if(names.get(position).toString().equals("PROFILE"))
{
imageView.setImageResource(R.drawable.ic_profile);
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent launchinIntent = new Intent(activity, profile_activity.class);
activity.startActivity(launchinIntent);
}
});
}
else if(names.get(position).toString().equals("CGPA CALCULATOR"))
{
imageView.setImageResource(R.drawable.ic_cgpa);
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent launchinIntent = new Intent(activity, cgpa_activity.class);
activity.startActivity(launchinIntent);
}
});
}
textView.setText(names.get(position).toString());
return v;
}
public static class createRequest extends DialogFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Get the layout inflater
LayoutInflater inflater = getActivity().getLayoutInflater();
final View v = inflater.inflate(R.layout.pick_period, null);
final DatePicker datePicker = (DatePicker) v.findViewById(R.id.datePicker);
final EditText hour = (EditText)v.findViewById(R.id.periodID);
final Spinner spn = (Spinner) v.findViewById(R.id.spinnerSubject);
String qu = "SELECT DISTINCT sub FROM NOTES";
ArrayList<String> subs = new ArrayList<>();
subs.add("Not Specified");
Cursor cr = AppBase.handler.execQuery(qu);
if(cr!=null)
{
cr.moveToFirst();
while(!cr.isAfterLast()) {
subs.add(cr.getString(0));
Log.d("gridAdapter.class", "Cached " + cr.getString(0));
cr.moveToNext();
}
}else
Log.d("gridAdapter.class", "No SUBS" + cr.getString(0));
ArrayAdapter<String> adapterSpinner = new ArrayAdapter<String>(activity, android.R.layout.simple_spinner_dropdown_item, subs);
assert spn != null;
spn.setAdapter(adapterSpinner);
builder.setView(v)
// Add action buttons
.setPositiveButton("Enter", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
int day = datePicker.getDayOfMonth();
int month = datePicker.getMonth() + 1;
int year = datePicker.getYear();
String date = year + "-" + month + "-" + day;
String subject = spn.getSelectedItem().toString();
String qx = "SELECT title FROM NOTES where sub = '" + subject + "'";
Cursor cr = AppBase.handler.execQuery(qx);
String subnames = "";
if(cr!=null)
{
cr.moveToFirst();
while(!cr.isAfterLast()) {
subnames += (cr.getString(0)) + "n";
cr.moveToNext();
}
}
makeNotification(subnames);
Cursor cursor = AppBase.handler.execQuery("SELECT * FROM ATTENDANCE WHERE datex = '" +
date +"' AND hour = " + hour.getText() + ";");
if(cursor==null||cursor.getCount()==0)
{
Intent launchinIntent = new Intent(AppBase.activity, attendanceActivity.class);
launchinIntent.putExtra("DATE", date);
launchinIntent.putExtra("PERIOD", hour.getText().toString());
AppBase.activity.startActivity(launchinIntent);
}else {
Toast.makeText(getActivity(),"Period Already Added",Toast.LENGTH_LONG).show();
}
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
return builder.create();
}
}
public static void makeNotification(String userIntrouble) {
Log.d("NOTIFICATION","Building..........");
Intent notificationIntent = new Intent(activity.getApplicationContext(), noteActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(activity, 0, notificationIntent,
0);
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(activity.getBaseContext());
Uri ring = Uri.parse(sharedPrefs.getString("Notification_Sound", Settings.System.DEFAULT_RINGTONE_URI.toString()));
NotificationCompat.Builder builder = new NotificationCompat.Builder(activity.getBaseContext())
.setTicker("Ticker Title").setContentTitle("Notes Are Available For this subject")
.setSmallIcon(R.drawable.ic_notes)
.setStyle(new NotificationCompat.BigTextStyle().bigText(userIntrouble))
.setContentIntent(pIntent)
.setSound(ring);
Notification noti = builder.build();
noti.contentIntent = pIntent;
noti.flags = Notification.FLAG_AUTO_CANCEL;
NotificationManager notificationManager = (NotificationManager) activity.getSystemService(activity.NOTIFICATION_SERVICE);
notificationManager.notify(0, noti);
}
}

Aitendancc Aciiviiy Create Dialoj 3:45 APR 27 2016 April 2016 10 11 2 13 1415 16 7 18 19 20 21 22 23 24 25 26 228 29 a0 EnterIntent launchinIntent = new Intent(AppBase.activity, attendanceActivity.class);
launchinIntent.putExtra("DATE", date);
launchinIntent.putExtra("PERIOD", hour.getText().toString());
AppBase.activity.startActivity(launchinIntent);

pref_general.xml

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<Preference
android:title="Clear Schedule data"
android:summary="Clear all schedules"
android:key="clear_schedule"/>
<Preference
android:title="Clear Attendance data"
android:summary="Clear all Attendance Data"
android:key="clear_attendance"/>
<Preference
android:title="Clear Notes data"
android:summary="Clear all Notes Data"
android:key="clear_notes"/>
<Preference
android:title="Clear Student data"
android:summary="Clear all Student Data"
android:key="clear_student"/>
</PreferenceScreen>

Screenshots: 3:46 S-Assistant S1 COMPUTER SCIENCE Name Roll Number Admission Number Contact SAVE← S-Assistant Title Here Body here S1 COMPUTER SCIENCE Subject Name SAVE Create new notea 3:47 ← S-Assistant Bio-Chemistry List of notes3:46 ← S-Assistant MONDAY S1 COMPUTER SCIENCE Subject Name 3:46A 12 10 2 4 AM PM Make New Schedule Activity

Add a comment
Know the answer?
Add Answer to:
Create a Student Planner app that will allow students to keep track of homework due dates...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student...

    I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student {    private String name;    private double gpa;    private int idNumber;    public Student() {        this.name = "";        this.gpa = 0;        this.idNumber = 0;    }    public Student(String name, double gpa, int idNumber) {        this.name = name;        this.gpa = gpa;        this.idNumber = idNumber;    }    public Student(Student s)...

  • Hi, I am trying to create a simple android app using spinners. It need not be...

    Hi, I am trying to create a simple android app using spinners. It need not be very complex. The app should allow the user to use a simple spinner to select a team from the following list of teams (Kansas City Chiefs, New England Patriots, New Orleans Saints, and the Los Angeles Rams), once the user selects the team they wish to view, the app should display a small paragraph of information (hardcoded) To the screen for the user to...

  • Write a Java program which will store, manipulate, and print student registration information. As part of...

    Write a Java program which will store, manipulate, and print student registration information. As part of the solution, identify the following classes: Student Admissions. The class Student must have the following fields – Name, Address, Id number, Courses, and Date, where: Name is a user defined class comprising of at minimum first name and last name. Address is a user defined class comprising of fields - street, city, state, and zip code. Date is a predefined class in the java.util...

  • Key Takeaways -To create 2 groups of 4 students (8 students in total) -NEEDS random GPAs for each student -No arrays ---...

    Key Takeaways -To create 2 groups of 4 students (8 students in total) -NEEDS random GPAs for each student -No arrays ------------------------------------- app.java, student.java, and group.java as requested below. Please use the diagram above to help answer the Question: Create a project that: Has a student class Instance variables for Firstname, last name , and age random generated GPA methods to return getinfo and semesterGPA Build upon the solutions of the previous labs (e.g., using app.java and student.java) You will...

  • The application should be in JAVA and allow: 1. Collect student information and store it in...

    The application should be in JAVA and allow: 1. Collect student information and store it in a binary data file. Each student is identified by an unique ID. The user should be able to view/edit an existing student. Do not allow the user to edit student ID. 2. Collect Course information and store it in a separate data file. Each course is identified by an unique ID. The user should be able to view/edit an existing course information. User is...

  • Java This application will be menu driven. The application should allow: 1. Collect student information and...

    Java This application will be menu driven. The application should allow: 1. Collect student information and store it in a binary data file. Each student is identified by an unique ID.   The user should be able to view/edit an existing student. Do not allow the user to edit student ID. 2. Collect Course information and store it in a separate data file. Each course is identified by an unique ID. The user should be able to view/edit an existing course...

  • You will create an Microsoft Access School Management System Database that can be used to store,...

    You will create an Microsoft Access School Management System Database that can be used to store, retrieve update and delete the staff/student. Design an Access database to maintain information about school staff and students satisfying the following properties: 1. The staff should have the following: ID#, name, and classes they are teaching 2. The student should have the following: ID#, name, section, class 3. Create a module containing the section, subject and teacher information 4. Create a module containing student...

  • Question 1 (24 Marks] 1. (4 marks) Write an immutable Person class in Java which provides...

    Question 1 (24 Marks] 1. (4 marks) Write an immutable Person class in Java which provides the following. • Two attributes: lastName and first Name of type String. • Appropriate initialization, accessors/mutator methods. 2. (6 marks) Write a Student class that is a subclass of Person class (in the previous question) which provides the following. • Two attributes: A unique student ID of type String and GPA of type float; the student ID is initialized when a Student object gets...

  • is due in 2 hours so i had to repost, sorry. Create an application that allows...

    is due in 2 hours so i had to repost, sorry. Create an application that allows you to manage a task list that’s stored in a database. using java and netbeans Console: Task List COMMAND MENU view - View pending tasks history -View completed tasks add -Add a task complete -Complete a task delete -Delete a task exit -Exit program Command: view 1. Buy toothbrush 2. Do homework Command: complete Number: 2 Command: add Description: Pay bills Command: view 1....

  • python 3 question Project Description Electronic gradebooks are used by instructors to store grades on individual assignments and to calculate students’ overall grades. Perhaps your instructor uses gr...

    python 3 question Project Description Electronic gradebooks are used by instructors to store grades on individual assignments and to calculate students’ overall grades. Perhaps your instructor uses gradebook software to keep track of your grades. Some instructors like to calculate grades based on what is sometimes called a “total points” system. This is the simplest way to calculate grades. A student’s grade is the sum of the points earned on all assignments divided by the sum of the points available...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT