0% found this document useful (0 votes)
60 views

Income Expenses Tracker

Mobile programming mini project

Uploaded by

Kapil Bohara
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Income Expenses Tracker

Mobile programming mini project

Uploaded by

Kapil Bohara
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

GYAN DEEP COLLEGE

Tulsipur Sub-Metropolitan City-06, Dang.


Affiliated to Tribhuwan University

LAB REPORT
ON
MOBILE PROGRAMMING

BACHELOR IN COMPUTER APPLICATIONS (BCA)


VI SEMESTER

Submitted by: Submitted to:


Kapil Bohora Gyan Deep College
Registration No. : 6-2-1084-9-2019 Department of BCA

(Signature of Subject Teacher)


ABSTRACT
I am going to make the Income/Expenses tracker android mobile app that
tracks daily income and expenses, displays available balance by calculating
income and expenses, also generates date wise income/expenses report. This
app doesn’t store data in remote server, but store data locally using SQLite.

The main aim of this project is to keep the record of daily income and
expenses and calculate the balance amount.
ACKNOWLEDGEMENT
The successful completion of this study is a culmination of so many people
lending their hands and minds. Though it would not be possible to
acknowledge everyone in their names, out here, we would like to take the
privilege to pay our gratitude to each and every individual associated
directly or indirectly with this study.

Foremost, it was an honor and great privilege to conduct this study under the
guidance of Mr. Ramesh Nagal, Software Engineer. We are grateful to him
for his invaluable support, suggestions and guidance throughout the study.
TABLE OF CONTENTS
1. INTRODUCTION
2. PURPOSE OF PROJECT
3. IMPLEMENTATION
3.1 INTRODUCTION TO MOBILE PROGRAMMING
3.2 ANDRIOD PLATFORM
3.3 HARDWARE REQUIREMENTS
3.4 FUNCTIONAL REQUIREMENTS
3.5 TECHNOLOGY USED
3.6 SOURCE CODE
4. SCREENSHOTS
5. CONCLUSION
6. REFERENCES
1. INTRODUCTION

In today's fast-paced world, managing personal finances has become increasingly


important. Whether you are an individual, a family, or a business, keeping track of
income and expenses is essential for maintaining financial stability and achieving your
financial goals. With the advent of technology, there are numerous tools and applications
available to assist in this process. In this mini project, we will develop an income and
expenses tracker that aims to provide a user-friendly interface and effective financial
management.

The income and Expenses Tracker Android App is a mini project aimed at developing a
mobile application that helps users to track their income and expenses.

This report provides an overview of the project.

2. PURPOSE OF PROJECT

The purpose of this project is to:

• Tracks daily income and expenses.


• Displays available balance by calculating income and expenses.
• Generates date wise income/expenses report.
• Store data locally using SQLite.

3. IMPLEMENTATION

System implementation specifies how the system is operated and maintained. It also
ensures that the system meets the quality standards. System implementation is the test
program that exercises the complete system in its actual environment to determine its
capabilities and limitations which also demonstrates that the system is functionally
operative, and is compatible with the other subsystems and supporting elements required
for its operational deployment.
3.1 Introduction to Mobile Programming:

Mobile programming is a set of processes and procedures involved in writing software


for small, wireless computing devices. It is the act or process by which mobile apps are
developed for mobile devices, such as personal digital assistants, enterprise digital
assistants or mobile phones.

There are two dominant platforms in the modern smartphone market. One is the iOS
platform from Apple Inc. The iOS platform is the operating system that powers Apple's
popular line of iPhone smartphones. The second is Android from Google. The Android
operating system is used not only by Google devices but also by many other OEMs to
build their own smartphones and other smart devices. An original equipment
manufacturer (OEM) is a company that produces parts and equipment that may be
marketed by another manufacturer.
There are several languages used for mobile programming. Languages like Java, Kotlin,
C#, Python etc. are popular for android platform and Objective-C, Swift etc. are popular
languages for iOS platform. Programmers can select any of the language of their choice
for writing mobile programs.
There are four major development approaches when building mobile applications:
• Native Mobile Applications
• Cross-Platform Native Mobile Applications
• Hybrid Mobile Applications
• Progressive Web Applications

Native Applications
Native mobile applications are written in the programming language and frameworks
provided by the platform owner and running directly on the operating system of the
device such as iOS and Android.

Cross-Platform Applications
Cross-platform native mobile applications can be written in variety of different
programming languages and frameworks, but they are compiled into a native application
running directly on the operating system of the device.
Hybrid-Web Applications
Hybrid mobile applications are built with standard web technologies - such as JavaScript,
CSS, and HTML5 - and they are bundled as app installation packages. Contrary to the
native apps, hybrid apps work on a 'web container' which provides a browser runtime and
a bridge for native device APIs via Apache Cordova.

Progressive Web Applications


WAs offer an alternative approach to traditional mobile app development by skipping
app store delivery and app installations. PWAs are web applications that utilize a set of
browser capabilities - such as working offline, running a background process, and adding
a link to the device home screen - to provide an 'app like' user experience.

Mobile Application Development Lifecycle


There are two interlinked core components of a mobile application: 1) the mobile
application “Front-End” that resides on the mobile device, and 2) the services “Back-
End” that supports the mobile front-end.

• The mobile front-end is the visual and interactive part of the application the user
experiences. It usually resides on the device, or there is at least an icon representing the
app that is visible on the home screen or is pinned in the application catlog of the device.
The application can be downloaded from the platform app store, side-loaded directly
onto the device, or can be reached through the device’s browser.
• Regardless of what front-end platform or development methodology is being used,
delivering high-quality mobile applications that delight and retain users requires reliable
back-end services.
• Given the critical importance of back-end services for the success of the mobile
application, the developers have several important architectural decisions that they must
consider. These decisions include which services should they build themselves and
which third party services should they leverage, and then should they run and maintain
their own services or should they take advantage of 3rd party services.

3.2 Android Platform:

Android is a mobile operating system currently developed by Google, based on the Linux
kernel and designed primarily for touchscreen mobile devices such as smartphones and
tablets. And as we said before, Android offers a unified approach to application
development for mobile devices.

Android is an open-source operating system named Android. Google has made the code
for all the low-level "stuff" as well as the needed middleware to power and use an
electronic device, and gave Android freely to anyone who wants to write code and build
the operating system from it. There is even a full application framework included, so
third-party apps can be built and installed, then made available for the user to run as they
like.
The "proper" name for this is the Android Open Source Project, and this is what people
mean when they say things like Android is open and free. Android, in this iteration, is
free for anyone to use as they like.

Environment Setup
In order to write an Android application, we are going to need a development
environment.
Google has made a very useful tool for all Android Developers, the Android Studio.
Android Studio is the official IDE for Android development, and with a single download
includes everything you need to begin developing Android apps.
Included in the download kit, are the Software Development Kit (SDK), with all the
Android libraries we may need, and the infrastructure to download the many Android
emulator instances, so that we can initially run our application, without needing a real
device. So, we are going to download and install Android Studio.

3.3 Hardware Requirements:

• Processor -> Intel(R) Core(TM) i3-1005G1 CPU @ 1.20GHz


1.19 GHz
• RAM -> 4GB or More
• HARD DISK -> 4GB or More

3.4 Functional Requirements:

• The system tracks daily income and expenses.


• The system keep the record of income and expenses.
• The system generates date wise income/expenses report

3.5 Technology Used:

• Programming Language: Java


• Development Framework: Android SDK (Software Development Kit)
• Integrated Development Environment (IDE): Android Studio
• Database: SQLite for local storage of income and expense data
• User Interface (UI) Design: XML layout files and Android UI components.

3.6 Source Code:

Dashboard
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Dashboard"
android:textSize="20sp"
android:id="@+id/dashboard"
android:layout_margin="10dp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:weightSum="2"
android:id="@+id/linear1"
android:layout_margin="10dp"
android:layout_below="@+id/dashboard"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_weight="1"
android:background="#FF69B4"
android:orientation="vertical"
android:padding="5dp"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="18sp"
android:textStyle="bold"
android:text="Today's Income" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/txtIncome"
android:layout_gravity="center"
android:textSize="18sp"
android:text="0" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:background="#FA8072"
android:layout_marginLeft="10dp"
android:padding="5dp"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="18sp"
android:textStyle="bold"
android:text="Today's Expenses" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/txtExpenses"
android:layout_gravity="center"
android:textSize="18sp"
android:text="0" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:weightSum="2"
android:id="@+id/linear2"
android:layout_margin="10dp"
android:layout_below="@+id/linear1"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_weight="1"
android:background="#F4A460"
android:orientation="vertical"
android:padding="10dp"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="18sp"
android:textStyle="bold"
android:text="Today's Balance" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/txtBalance"
android:layout_gravity="center"
android:textSize="18sp"
android:text="0" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:background="#DA70D6"
android:layout_marginLeft="10dp"
android:padding="10dp"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="18sp"
android:textStyle="bold"
android:gravity="center"
android:id="@+id/txtDetails"
android:padding="1dp"
android:lines="2"
android:text="View Today's Details" />
</LinearLayout>
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Enter Income/Expenses"
android:textAllCaps="false"
android:textSize="18sp"
android:layout_below="@+id/linear2"
android:layout_margin="10dp"
android:id="@+id/btnEntry"
android:background="#9370DB"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Date Wise Report"
android:textAllCaps="false"
android:textSize="18sp"
android:layout_below="@+id/btnEntry"
android:layout_margin="10dp"
android:id="@+id/btnReport"
android:background="#4682B4"/>
</RelativeLayout>
MainActivity.java
package com.example.project;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.text.SimpleDateFormat;
import java.util.Date;

public class MainActivity extends AppCompatActivity {

TextView txtIncome,txtExpenses,txtBalance,txtDetails;
Button btnEntry,btnReport;
MyDatabase myDatabase;
Cursor cursor;
@Override
protected void onCreate(Bundle b){
super.onCreate(b);
setContentView(R.layout.activity_main);
txtIncome=findViewById(R.id.txtIncome);
txtExpenses=findViewById(R.id.txtExpenses);
txtBalance=findViewById(R.id.txtBalance);
txtDetails=findViewById(R.id.txtDetails);
btnEntry=findViewById(R.id.btnEntry);
btnReport=findViewById(R.id.btnReport);
myDatabase=new MyDatabase(this);
btnEntry.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent=new Intent(MainActivity.this,
DataEntry.class);
startActivity(intent);
}
});
txtDetails.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent=new Intent(MainActivity.this,
TodayDetails.class);
startActivity(intent);
}
});
btnReport.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent=new Intent(MainActivity.this,
DateWiseReport.class);
startActivity(intent);
}
});
}
@Override
protected void onResume(){
super.onResume();
//displaying data of current date
loadData();
}
public void loadData(){
cursor=myDatabase.selectData(getCurrentDate());
int income=0,expenses=0,balance=0;
while (cursor.moveToNext()){
income+=cursor.getInt(2);
expenses+=cursor.getInt(3);
}
balance=income-expenses;
txtIncome.setText(income+"");
txtExpenses.setText(expenses+"");
txtBalance.setText(balance+"");
}
public static String getCurrentDate(){
//current date
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
String dat=formatter.format(date);
return dat;
}
}

Data Entry
data_entry.xml
<?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">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Date"
android:id="@+id/edtDate"
android:inputType="date"
android:layout_margin="10dp" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:entries="@array/title"
android:id="@+id/spTitle" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Amount"
android:id="@+id/edtAmount"
android:inputType="number"
android:layout_margin="10dp" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="Submit"
android:id="@+id/btnSubmit"/>
</LinearLayout>

DataEntry.java
package com.example.project;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class DataEntry extends AppCompatActivity {


EditText edtDate,edtAmount;
Spinner spTitle;
Button btnSubmit;
MyDatabase myDatabase;
@Override
protected void onCreate(Bundle b){
super.onCreate(b);
setContentView(R.layout.data_entry);
edtDate=findViewById(R.id.edtDate);
edtAmount=findViewById(R.id.edtAmount);
spTitle=findViewById(R.id.spTitle);
btnSubmit=findViewById(R.id.btnSubmit);
myDatabase=new MyDatabase(this);
edtDate.setText(MainActivity.getCurrentDate());
btnSubmit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//getting data
String date=edtDate.getText().toString();
String title=spTitle.getSelectedItem().toString();
String amount=edtAmount.getText().toString();
//validating data
if(date.equals("")){
Toast.makeText(DataEntry.this,"Please Enter Date !",
Toast.LENGTH_LONG).show();
} else if(amount.equals("")) {
Toast.makeText(DataEntry.this,
"Please Enter Amount !",Toast.LENGTH_LONG).show();
} else if(title.equals("Select Title")){
Toast.makeText(DataEntry.this,
"Please Select Title !",Toast.LENGTH_LONG).show();
}else{
//checking income or expenses
if(title.equals("Income"))
myDatabase.insertData(date,amount,"0");
else
myDatabase.insertData(date,"0",amount);
Toast.makeText(DataEntry.this,
"Data Inserted Successfully !",Toast.LENGTH_LONG).show();
edtAmount.setText("");
spTitle.setSelection(0);
}
}
});
}
}

Database
MyDatabase.java
package com.example.project;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class MyDatabase extends SQLiteOpenHelper {


// Database Version
private static final int DATABASE_VERSION = 1;
// Database Name
private static final String DATABASE_NAME = "mydatabase";
public MyDatabase(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
// Creating Tables
@Override
public void onCreate(SQLiteDatabase db) {
// create notes table
String createQuery="CREATE TABLE mytable(id INTEGER PRIMARY KEY
AUTOINCREMENT,date TEXT,income TEXT,expenses TEXT)";
db.execSQL(createQuery);
}
// Upgrading database
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int
newVersion) {
// Drop older table if existed
db.execSQL("DROP TABLE IF EXISTS " + DATABASE_NAME);
// Create tables again
onCreate(db);
}
//code to insert data
public void insertData(String date,String income, String expenses){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues=new ContentValues();
contentValues.put("date",date);
contentValues.put("income",income);
contentValues.put("expenses",expenses);
//inserting row
db.insert("mytable",null,contentValues);
db.close();
}
//code to select data
public Cursor selectData(String date){
SQLiteDatabase db=this.getReadableDatabase();
String query="SELECT * FROM mytable WHERE date=?";
Cursor cursor=db.rawQuery(query,new String[]{date});
return cursor;
}
public Cursor selectData(String date1, String date2){
SQLiteDatabase db=this.getReadableDatabase();
String query="SELECT * FROM mytable WHERE date BETWEEN ? AND ?";
Cursor cursor=db.rawQuery(query,new String[]{date1,date2});
return cursor;
}
//code to update data
public void updateData(String id,String date, String income, String
expenses){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues=new ContentValues();
contentValues.put("date",date);
contentValues.put("income",income);
contentValues.put("expenses",expenses);
//updating row
db.update("mytable",contentValues,"id=?",new String[]{id});
db.close();
}
//code to delete data
public void deleteData(String id) {
SQLiteDatabase db = this.getWritableDatabase();
//deleting row
db.delete("mytable","id=?",new String[]{id});
}
}

Displaying Today’s Details


today_details.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>

list_items.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:id="@+id/relat"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Date: 2020-04-03"
android:layout_margin="10dp"
android:id="@+id/txtDate"
android:textStyle="bold"
android:textSize="18sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Income: 20000"
android:layout_margin="10dp"
android:id="@+id/txtIncome"
android:textStyle="bold"
android:layout_toRightOf="@+id/txtDate"
android:textColor="#3F51B5"
android:visibility="gone"
android:textSize="18sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Expenses: 10000"
android:layout_margin="10dp"
android:id="@+id/txtExpenses"
android:textStyle="bold"
android:layout_toRightOf="@+id/txtDate"
android:textColor="#FF4081"
android:visibility="gone"
android:textSize="18sp" />
</RelativeLayout>

DataModel.java
package com.example.project;
public class DataModel {
private int id;
private String date;
private int income;
private int expenses;
public DataModel(int id,String date,int income,int expenses){
this.id=id;
this.date=date;
this.income=income;
this.expenses=expenses;
}
public int getId(){
return id;
}
public String getDate(){
return date;
}
public int getIncome(){
return income;
}
public int getExpenses(){
return expenses;
}}

RecyclerViewAdapter.java
package com.example.project;
import android.app.Activity;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;

public class RecyclerViewAdapter extends


RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder> {
Activity context;
ArrayList<DataModel> data;
public RecyclerViewAdapter(Activity context, ArrayList<DataModel>
data){
this.context=context;
this.data=data;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
{
LayoutInflater layoutInflater = LayoutInflater.from(context);
View listItem= layoutInflater.inflate(R.layout.list_items,
parent, false);
ViewHolder viewHolder = new ViewHolder(listItem);
return viewHolder;
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
final DataModel current=data.get(position);
holder.txtDate.setText("Date: "+current.getDate());
if(current.getExpenses()==0){
holder.txtExpenses.setVisibility(View.GONE);
holder.txtIncome.setVisibility(View.VISIBLE);
holder.txtIncome.setText("Income: "+current.getIncome());
}else{
holder.txtExpenses.setVisibility(View.VISIBLE);
holder.txtIncome.setVisibility(View.GONE);
holder.txtExpenses.setText("Expenses: "+
current.getExpenses());
}
holder.relativeLayout.setOnClickListener(new View.
OnClickListener() {
@Override
public void onClick(View view) {
Intent intent=new Intent(context,ModifyDetails.class);
intent.putExtra("id",current.getId());
intent.putExtra("date",current.getDate());
if(current.getExpenses()==0)
intent.putExtra("amount",current.getIncome());
else
intent.putExtra("amount",current.getExpenses());
context.startActivity(intent);
}
});
}
@Override
public int getItemCount() {
return data.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
TextView txtDate,txtIncome,txtExpenses;
RelativeLayout relativeLayout;
public ViewHolder(View itemView) {
super(itemView);
txtDate = itemView.findViewById(R.id.txtDate);
txtIncome = itemView.findViewById(R.id.txtIncome);
txtExpenses = itemView.findViewById(R.id.txtExpenses);
relativeLayout=itemView.findViewById(R.id.relat);
}
}
}

TodayDetails.java
package com.example.project;
import android.database.Cursor;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;

public class TodayDetails extends AppCompatActivity {


RecyclerView recyclerView;
RecyclerView.Adapter recyclerAdapter;
RecyclerView.LayoutManager layoutManager;
MyDatabase myDatabase;
Cursor cursor;
@Override
protected void onCreate(Bundle b){
super.onCreate(b);
setContentView(R.layout.today_details);
recyclerView=findViewById(R.id.recyclerview);
myDatabase=new MyDatabase(this);
}
@Override
protected void onResume(){
super.onResume();
loadData();
}
public void loadData(){
cursor=myDatabase.selectData(MainActivity.getCurrentDate());
ArrayList<DataModel> data=new ArrayList<>();
while (cursor.moveToNext()){
int id=cursor.getInt(0);
String date=cursor.getString(1);
int income=cursor.getInt(2);
int expenses=cursor.getInt(3);
DataModel dataModel=new DataModel(id,date,income,expenses);
data.add(dataModel);
}
layoutManager=new LinearLayoutManager(this);
recyclerAdapter=new RecyclerViewAdapter(this,data);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(recyclerAdapter);
}
}
Date wise Report
datewise_report.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Between:"
android:layout_margin="10dp"
android:textSize="18sp"
android:textStyle="bold"
android:id="@+id/between" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter Date"
android:textSize="18sp"
android:inputType="date"
android:layout_toRightOf="@+id/between"
android:id="@+id/edtDate1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="and"
android:layout_margin="10dp"
android:layout_toRightOf="@+id/edtDate1"
android:textSize="18sp"
android:textStyle="bold"
android:id="@+id/and" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter Date"
android:textSize="18sp"
android:inputType="date"
android:layout_toRightOf="@+id/and"
android:id="@+id/edtDate2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="submit"
android:id="@+id/btnSubmit"
android:layout_below="@+id/between"
android:layout_centerHorizontal="true" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_marginTop="10dp"
android:scrollbars="vertical"
android:layout_below="@+id/btnSubmit"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>

DateWiseReport.java
package com.example.project;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;

public class DateWiseReport extends AppCompatActivity {


RecyclerView recyclerView;
RecyclerView.Adapter recyclerAdapter;
RecyclerView.LayoutManager layoutManager;
MyDatabase myDatabase;
Cursor cursor;
EditText edtDate1,edtDate2;
Button btnSubmit;
@Override
protected void onCreate(Bundle b){
super.onCreate(b);
setContentView(R.layout.datewise_report);
recyclerView=findViewById(R.id.recyclerview);
myDatabase=new MyDatabase(this);
edtDate1=findViewById(R.id.edtDate1);
edtDate2=findViewById(R.id.edtDate2);
btnSubmit=findViewById(R.id.btnSubmit);
btnSubmit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
loadData();
}
});
}
public void loadData(){
String date1=edtDate1.getText().toString();
String date2=edtDate2.getText().toString();
if(date1.equals("")||date2.equals("")){
Toast.makeText(DateWiseReport.this,"Please Enter Date !",
Toast.LENGTH_LONG).show();
}else{
cursor=myDatabase.selectData(date1,date2);
ArrayList<DataModel> data=new ArrayList<>();
while (cursor.moveToNext()){
int id=cursor.getInt(0);
String date=cursor.getString(1);
int income=cursor.getInt(2);
int expenses=cursor.getInt(3);
DataModel dataModel=new DataModel(id,date,income,
expenses);
data.add(dataModel);
}
layoutManager=new LinearLayoutManager(this);
recyclerAdapter=new RecyclerViewAdapter(this,data);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(recyclerAdapter);
}}}

Modifying Data
modify_details.xml
<?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">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Date"
android:id="@+id/edtDate"
android:inputType="date"
android:layout_margin="10dp" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:entries="@array/title"
android:id="@+id/spTitle" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Amount"
android:id="@+id/edtAmount"
android:inputType="number"
android:layout_margin="10dp" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="Update"
android:id="@+id/btnUpdate"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="Delete"
android:id="@+id/btnDelete"/>
</LinearLayout>
ModifyDetails.java
package com.example.project;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class ModifyDetails extends AppCompatActivity {


EditText edtDate,edtAmount;
Spinner spTitle;
Button btnUpdate,btnDelete;
MyDatabase myDatabase;
int id=0,amount=0;
String date="";
@Override
protected void onCreate(Bundle b){
super.onCreate(b);
setContentView(R.layout.modify_details);
edtDate=findViewById(R.id.edtDate);
edtAmount=findViewById(R.id.edtAmount);
spTitle=findViewById(R.id.spTitle);
btnUpdate=findViewById(R.id.btnUpdate);
btnDelete=findViewById(R.id.btnDelete);
myDatabase=new MyDatabase(this);
Intent intent=getIntent();
id=intent.getIntExtra("id",0);
date=intent.getStringExtra("date");
amount=intent.getIntExtra("amount",0);
edtDate.setText(date);
edtAmount.setText(amount+"");
btnDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
myDatabase.deleteData(String.valueOf(id));
Toast.makeText(ModifyDetails.this,
"Data Deleted Successfully !",Toast.LENGTH_LONG).show();
finish();
}
});
btnUpdate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//getting data
String date=edtDate.getText().toString();
String title=spTitle.getSelectedItem().toString();
String amount=edtAmount.getText().toString();
//validating data
if(date.equals("")){
Toast.makeText(ModifyDetails.this,
"Please Enter Date !",Toast.LENGTH_LONG).show();
} else if(amount.equals("")) {
Toast.makeText(ModifyDetails.this,
"Please Enter Amount !", Toast.LENGTH_LONG).show();
} else if(title.equals("Select Title")){
Toast.makeText(ModifyDetails.this,
"Please Select Title !",Toast.LENGTH_LONG).show();
}else{
//checking income or expenses
if(title.equals("Income"))
myDatabase.updateData(String.valueOf(id),
date,amount,"0");
else
myDatabase.updateData(String.valueOf(id),
date,"0",amount);
Toast.makeText(ModifyDetails.this,
"Data Updated Successfully !",Toast.LENGTH_LONG).show();
finish();
}
}
});
}
}

Manifest File
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.Project"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />


</intent-filter>
</activity>
<activity android:name=".DataEntry" android:label="Data Entry"/>
<activity android:name=".TodayDetails" android:label="Today's
Details"/>
<activity android:name=".ModifyDetails" android:label="Modify
Details"/>
<activity android:name=".DateWiseReport" android:label="Date Wise
Report"/>
</application>

</manifest>
4. SCREENSHOTS

Home Screen
Data Entry Screen
Today's Details Screen
Date Wise Report Screen
Modify Details Screen
5. CONCLUSION

The Income and Expenses Tracker Android App mini project aimed to provide a user-
friendly solution for tracking income and expenses. The app successfully implemented
the core features, allowing users to keep the record of the daily income and expenses
efficiently. It provides a visually appealing user interface, generates reports of data wise
income and expenses.

6. REFERENCES

[1] Mobile Programming, BCA 6th Semester, KEC PUBLICATION AND


DISTRIBUTION PVT.LTD. Kathmandu

[2] https://drive.google.com/file/d/1ptyptocCMCw32nIr7tqx3jfR4EPbzEue/view

[3] https://www.youtube.com/watch?v=PmiSj2QGZVM

You might also like