Free Projects developed by Java, C# and PHP

Daily Expense Manager app


We have many web application and mobile applications in GitHub for public use.

This project specifically developed to show how we can implement a simple 
android application to access and manage call logs on an android device 
in Android Studio with Java.

The project contains 1 main activity described below:
	- Splash Activity Activity: is used to demonstrate how we can implement 
	  splash screens that will popup when the app 
	  opens and navigate to main activity after a few seconds
	- Main Activity Activity: is used to show the main landing page for the application
	- Login Activity Activity: is used to show the login window
	- Add Activity Activity: is used to show how to add new diary content into SQLite database
	- Search Activity Activity: is used to show how to implement searching a record 
	  from a SQLite database
	- Show All Activity Activity: is used to show all SQLite database records and 
	  load them to a ListView


DBHelper.java:
===============================================================================================
package nebiyou.dailyexpensemanager;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by it on 4/29/2009.
 */

public class DBHelper extends SQLiteOpenHelper {

    public DBHelper(Context context) {
        super(context,"DailyDatabase",null,1);

    }

    public DBHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String query = "CREATE TABLE tbldaily (Date TEXT, reason TEXT , amount TEXT)";
        db.execSQL(query);
    }

    public void AddNewDiary(DailyModel dailyModel){
        ContentValues values = new ContentValues();
        values.put("Date",dailyModel.getDate());
        values.put("reason",dailyModel.getReasone());
        values.put("amount",dailyModel.getAmount());

        SQLiteDatabase db =getWritableDatabase();
        db.insert("tbldaily",null, values) ;


    }

    public DailyModel Search(String Dailydate){
        String query = "SELECT Date, reason,amount FROM tbldaily WHERE Date=?";
        String[] criteria = {Dailydate};

        SQLiteDatabase db = getReadableDatabase();
        Cursor cursor = db.rawQuery(query, criteria);

        if(cursor != null){
            cursor.moveToFirst();

            DailyModel dailyModel=new DailyModel();

            dailyModel.setReasone(cursor.getString(1));
            dailyModel.setAmount(cursor.getString(2));
            return dailyModel;
        }
        else{
            return null;
        }



    }

    public List<DailyModel> ShowAll (){
        String query ="SELECT date,reason,amount FROM tbldaily ";
        String[] criteria = {};

        SQLiteDatabase db = getReadableDatabase();
        Cursor cursor = db.rawQuery(query, criteria);

        List<DailyModel> dailyModels = new ArrayList<>();
        if(cursor != null){
            cursor.moveToFirst();
            do{
                DailyModel dailyModel=new DailyModel();
                dailyModel.setDate(cursor.getString(0));
                dailyModel.setReasone(cursor.getString(1));
                dailyModel.setAmount(cursor.getString(2));

                dailyModels.add(dailyModel);
            }while(cursor.moveToNext());

            return dailyModels;
        }
        else{
            return null;
        }
    }




        @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

        }

}