Tamamını indir

package com.example.ali.kopyalakaydet.Service;

import android.app.Service;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.ContentValues;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.widget.Toast;
import com.example.ali.kopyalakaydet.Database.database;
import java.text.SimpleDateFormat;
import java.util.Date;
public class KopyalaService extends Service {
    ClipboardManager cm;
    SQLiteDatabase db;
    database vt;
    @Nullable
    @Override
    public IBinder onBind(Intent ıntent) {
        return null;
    }

    @Override
    public void onCreate() {
        super.onCreate();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        cm = (ClipboardManager) getSystemService(Service.CLIPBOARD_SERVICE);

                    cm.addPrimaryClipChangedListener(new ClipboardManager.OnPrimaryClipChangedListener() {
                        @Override
                        public void onPrimaryClipChanged() {
                           try {
                               vt = new database(getApplicationContext());
                               db = vt.getWritableDatabase();
                               ClipData cd = cm.getPrimaryClip();
                               String item=cd.getItemAt(0).getText() + "";
                               ContentValues par=new ContentValues();
                               par.put("ITEM",item);
                               SimpleDateFormat frm=new SimpleDateFormat("yyyy-MM-dd");
                               par.put("DATE",frm.format(new Date()));
                               db.insertOrThrow("COPYITEMS",null,par);
                               Toast.makeText(getApplicationContext(),item+" Kayıt Edildi.", Toast.LENGTH_LONG).show();
                               db.close();
                           }
                           catch (Exception ex)
                           {
                               Toast.makeText(getApplicationContext(),"Hata="+ex.getMessage(), Toast.LENGTH_LONG).show();
                           }
                           }
                    });

      return  super.onStartCommand(intent, flags, startId);
    }

}

 


Basit ad,soyad,yas ekleme,silme,güncelleme uygulaması yapacağız.

Asp .net Mssql Bağlantısı

Asp ile Mssql’e connection ve insert,delete,update,select işlemleri yapacak bir asp uygulaması yazarız. Ardından asp uygulamamızı windows hosting’e atmak için asp projemizi Publish ederiz. Hosting’e atarız. Bu uygulama database bağlanır ekleme,silme,güncelleme işlemlerinin ardından verileri json( için Newtonsoft.Json kütüphanesini kullandım) şekilde listeleyerek döndürür.
(Not:Denemek için somee.com sitesinden free hosting kullanabilirsiniz.)
Asp uygulamasının tamamını indir

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace db
{
    public partial class _default : System.Web.UI.Page
    {
        SqlConnection baglanti;
        SqlCommand sorgu;
        SqlDataReader veri_oku;
        SqlTransaction tran;
        List<kisi> liste;
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                baglanti = new SqlConnection("workstation id=kisiler.mssql.somee.com;packet size=4096;user id=alideneme_SQLLogin_1;pwd=oky1e9kvaw;data source=kisiler.mssql.somee.com;persist security info=False;initial catalog=kisiler");
                
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
                return;
            }
            if (Request.Form["durum"] != null && Request.Form["durum"].Equals("0"))//Post ile durum eğerse 0 ise kisileri listele
            {
                kisi_getir();
            }
            if (Request.Form["durum"] != null && Request.Form["durum"].Equals("1"))//durum eğer 1 kisi ekle
            {
                kisi_ekle(Request.Form["ad"], Request.Form["soyad"], Convert.ToInt32(Request.Form["yas"]));
                kisi_getir();
            }
            if (Request.Form["durum"] != null && Request.Form["durum"].Equals("2"))
            {
                kisi_sil(Convert.ToInt32(Request.Form["id"]));
                kisi_getir();
            }
            if (Request.Form["durum"] != null && Request.Form["durum"].Equals("3"))
            {
                kisi_guncelle(Request.Form["ad"], Request.Form["soyad"], Convert.ToInt32(Request.Form["yas"]), Convert.ToInt32(Request.Form["id"]));
                kisi_getir();
            }
        }
        private void baglan()
        {
            try
            {
                if (baglanti.State == ConnectionState.Closed)
                    baglanti.Open();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);

            }
        }
        private void kapat()
        {
            try
            {
                if (baglanti.State == ConnectionState.Open)
                    baglanti.Close();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }

        }
        public void kisi_ekle(string ad, string soyad, int yas)
        {
            try
            {
                baglan();
                sorgu = baglanti.CreateCommand();
                sorgu.CommandText = "insert into kisi(ad,soyad,yas) values(@ad,@soyad,@yas)";
                tran = baglanti.BeginTransaction();
                sorgu.Transaction = tran;
                sorgu.Parameters.AddWithValue("@ad", ad);
                sorgu.Parameters.AddWithValue("@soyad", soyad);
                sorgu.Parameters.AddWithValue("@yas", yas);
                sorgu.ExecuteNonQuery();
                tran.Commit();
                kapat();
            }
            catch (Exception ex)
            {
                if (baglanti != null)
                    tran.Rollback();
                Response.Write(ex.Message);
            }
        }
        public void kisi_sil(int id)
        {
            try
            {
                baglan();
                sorgu = baglanti.CreateCommand();
                sorgu.CommandText = "delete from kisi where id=@id";
                tran = baglanti.BeginTransaction();
                sorgu.Transaction = tran;
                sorgu.Parameters.AddWithValue("@id", id);
                sorgu.ExecuteNonQuery();
                tran.Commit();
                kapat();
            }
            catch (Exception ex)
            {
                if (baglanti != null)
                    tran.Rollback();
                Response.Write(ex.Message);
            }
        }
        public void kisi_guncelle(string ad, string soyad, int yas, int id)
        {
            try
            {
                baglan();
                sorgu = baglanti.CreateCommand();
                sorgu.CommandText = "update kisi set ad=@ad,soyad=@soyad,yas=@yas where id=@id";
                tran = baglanti.BeginTransaction();
                sorgu.Transaction = tran;
                sorgu.Parameters.AddWithValue("@ad", ad);
                sorgu.Parameters.AddWithValue("@soyad", soyad);
                sorgu.Parameters.AddWithValue("@yas", yas);
                sorgu.Parameters.AddWithValue("@id", id);
                sorgu.ExecuteNonQuery();
                tran.Commit();
                kapat();
            }
            catch (Exception ex)
            {
                if (baglanti != null)
                    tran.Rollback();
                Response.Write(ex.Message);
            }
        }
        public void kisi_getir()
        {
            try
            {
                baglan();
                sorgu = baglanti.CreateCommand();
                sorgu.CommandText = "select id,ad,soyad,yas from kisi order by id desc";
                tran = baglanti.BeginTransaction();
                sorgu.Transaction = tran;
                veri_oku = sorgu.ExecuteReader();
                liste = new List<kisi>();
                while (veri_oku.Read())
                { 
                    kisi k=new kisi();
                    k.id=Convert.ToInt32(veri_oku[0]);
                    k.ad=veri_oku[1]+"";
                    k.soyad=veri_oku[2]+"";
                    k.yas=Convert.ToInt32(veri_oku[3]);
                    liste.Add(k);
                }

                string json = JsonConvert.SerializeObject(liste);
                veri_oku.Close();
                tran.Commit();
                kapat();
                Response.Write(json);
            }
            catch (Exception ex)
            {
                if (baglanti != null)
                    tran.Rollback();
                Response.Write(ex.Message);
            }
        }
    }
}

Android Asp Web Sayfasına Post İşlemi

Android tarafında HttpURLConnection sınıfı ile http isteği oluşturup Uri.Builder sınıfı ile post paremetrelerini ayarlayıp asp web sayfasına post isteği gönderiyoruz(Ekleme,Silme,Güncelleme için) Geriye dönen json şeklindeki veriyi parse ederek listview’e yazdırıyoruz.
Android Asp sayfasına Post ve İşlemler tamamını indir

GPS Kullanım Tamamını indir

package com.example.ali.gpskullanm;

import android.Manifest;
import android.app.AlertDialog;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import java.io.BufferedWriter;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    LocationListener ll;
    LocationManager lm;
    Context c;
    double enlem, boylam;
    TextView tenlem,tboylam;
    ConnectivityManager cm;
    NetworkInfo networkinfo;
    AlertDialog.Builder dialog;
    int saat=(1000*60*60);
    vt vt_sinfi;
    SQLiteDatabase db;
    Button btn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        c = this;
        vt_sinfi=new vt(c);
        btn=(Button)findViewById(R.id.btn);
        btn.setOnClickListener(this);

        tenlem=(TextView)findViewById(R.id.enlem);
        tboylam=(TextView)findViewById(R.id.boylam);
        dialogcreate();

    }
    public void dialogcreate()
    {
        dialog=new AlertDialog.Builder(c);
        dialog.setTitle("Konum");
        dialog.setMessage("Konumu Açınız!!");
        dialog.setPositiveButton("Tamam", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {

            }
        });
        dialog.create().show();
    }
    public void init()
    {
        lm=null;
        lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        ll = new LocationListener() {
            @Override
            public void onLocationChanged(Location location) {
                enlem = location.getLatitude();
                boylam = location.getLongitude();
                tenlem.setText(enlem+"");
                tboylam.setText(boylam+"");
                cm=(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
                networkinfo=(NetworkInfo) cm.getActiveNetworkInfo();
                if(networkinfo!=null&&networkinfo.isConnected())
                {
                    if(veri_kontrol())
                        sunucuya_ekle();
                    post(enlem+"",boylam+"");
                }
                else
                {
                    konum_ekle(enlem+"",boylam+"");
                    Toast.makeText(c, "Konum veritabnına kayıtedildi", Toast.LENGTH_LONG).show();
                }
                lm.removeUpdates(ll);

            }
            @Override
            public void onStatusChanged(String s, int i, Bundle bundle) {

            }
            @Override
            public void onProviderEnabled(String s) {
                Toast.makeText(c, "GPS Veri bilgileri Alınıyor...", Toast.LENGTH_LONG).show();
            }
            @Override
            public void onProviderDisabled(String s) {
                Toast.makeText(c, "GPS Bağlantı Bekleniyor...", Toast.LENGTH_LONG).show();
            }
        };
        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            Toast.makeText(c,"Konum açınız!!!",Toast.LENGTH_LONG).show();
            return;
        }
        if(networkinfo!=null&&networkinfo.isConnected()) {//bağlandı ise tru döndürür
            lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,6000,0, ll);
        }
        else
        {
            lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 6000, 0, ll);
        }
    }
    public  void post(final String enlem, final String boylam)
    {

        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    URL url = new URL("http://alikomesogutlu.org/yandexmap.php");
                    HttpURLConnection  conn = (HttpURLConnection) url.openConnection();
                    conn.setReadTimeout(10000);
                    conn.setConnectTimeout(15000);
                    conn.setRequestMethod("POST");
                    conn.setDoInput(true);
                    conn.setDoOutput(true);

                    Uri.Builder builder = new Uri.Builder()
                            .appendQueryParameter("enlem",enlem)
                            .appendQueryParameter("boylam", boylam);
                    String query = builder.build().getEncodedQuery();

                    OutputStream os = conn.getOutputStream();//bağlantının cıkısı
                    BufferedWriter writer = new BufferedWriter(
                            new OutputStreamWriter(os, "UTF-8"));
                    writer.write(query);
                    writer.flush();
                    writer.close();
                    os.close();
                    conn.connect();
                    Log.d("hata",conn.getResponseMessage());
                }
                catch (Exception ex)
                {

                }
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {

                        Toast.makeText(c,"Konum sunucuya kayıt edildi.",Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }).start();
    }
    public void baglan()
    {
        try {
            db=vt_sinfi.getWritableDatabase();
        }
        catch (Exception ex)
        {
            Toast.makeText(c,ex.getMessage(),Toast.LENGTH_SHORT).show();
        }
    }
    public void konum_ekle(String enlem,String boylam)
    {
        try {
            baglan();
            ContentValues par=new ContentValues();
            par.put("enlem",enlem);
            par.put("boylam",boylam);
            db.insertOrThrow("konum",null,par);
            db.close();
        }
        catch (Exception ex)
        {
            Toast.makeText(c,ex.getMessage(),Toast.LENGTH_SHORT).show();
        }
    }
    public void sunucuya_ekle()
    {
        try {
            baglan();
            Cursor cursor=db.query("konum",new String[]{"enlem","boylam"},null,null,null,null,null);
            cursor.moveToPosition(-1);
            while (cursor.moveToNext())
                post(cursor.getString(0),cursor.getString(1));
            cursor.close();
            vt_sinfi.onUpgrade(db,0,0);
            db.close();
        }
        catch (Exception ex)
        {
            Toast.makeText(c,ex.getMessage(),Toast.LENGTH_SHORT).show();
        }
    }
    public boolean veri_kontrol()
    {
        try {
            baglan();
            Cursor cursor=db.rawQuery("select * from konum",null);
            if(cursor.getCount()>0)
            {   db.close();
                return true;
            }
            else {
                db.close();
                return false;
            }
        }
        catch (Exception ex)
        {
            Toast.makeText(c,ex.getMessage(),Toast.LENGTH_SHORT).show();
            return false;
        }
    }

    @Override
    public void onClick(View view) {
        init();
    }
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8"/>
<?php
$enlem='36.584014';
$boylam='36.163995'; 
if(isset($_POST['konum']))
{
	$enlem_boylam=explode(",",$_POST['konum']);
	$enlem=$enlem_boylam[0];
	$boylam=$enlem_boylam[1];

}
if(isset($_POST['enlem'])&&isset($_POST['boylam']))
{
$dosya=fopen('konum.txt','a');
fwrite($dosya,$_POST['enlem'].",".$_POST['boylam']."-");
fclose($dosya);
}
else
{
	try{
$dosya=fopen('konum.txt','r');
$boyut=filesize('konum.txt');
$veri=fread($dosya,$boyut);
fclose($dosya);
$konum=explode("-",$veri);

	}
	catch(Exception $ex)
	{
		echo $ex->getMessage();
	}
?>
    <title>YMapsML examples. Map parameters</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	 <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20src%3D%22http%3A%2F%2Fapi-maps.yandex.ru%2F2.0%2F%3Fload%3Dpackage.full%26lang%3Dtr-TR%22%20type%3D%22text%2Fjavascript%22%3E%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="<script>" title="<script>" />
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20type%3D%22text%2Fjavascript%22%3E%0D%0Aymaps.ready(init)%3B%0D%0Afunction%20init%20()%20%7B%0D%0A%20%20%20var%20myMap%20%3D%20new%20ymaps.Map('map'%2C%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20center%3A%20%5B%3C%3Fphp%20echo%20%24enlem%3B%3F%3E%2C%20%3C%3Fphp%20echo%20%24boylam%3B%3F%3E%5D%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20zoom%3A%2012%0D%0A%20%20%20%20%20%20%20%7D)%2C%0D%0A%20%20%20%20%20%20%20myPlacemark%20%3D%20new%20ymaps.Placemark(%5B%3C%3Fphp%20echo%20%24enlem%3B%3F%3E%2C%20%3C%3Fphp%20echo%20%24boylam%3B%3F%3E%5D%2C%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20content%3A%20'%C4%B0skenderun!'%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20balloonContent%3A%20'Buradas%C4%B1n%C4%B1z!!!!'%0D%0A%20%20%20%20%20%20%20%7D)%3B%0D%0A%20%20%20myMap.controls%0D%0A%20%20%20%20%20%20%20.add('searchControl'%2C%20%7B%20left%3A5%2C%20top%3A%205%20%7D)%0D%0A%20%20%20%20%20%20%20.add('smallZoomControl'%2C%20%7B%20left%3A%205%2C%20top%3A%20165%20%7D)%0D%0A%20%20%20%20%20%20%20.add('typeSelector')%0D%0A%20%20%20%20%20%20%20.add('mapTools'%2C%20%7B%20left%3A%205%2C%20top%3A%20460%20%7D)%0D%0A%20%20%20%20%20%20%20.add('trafficControl'%2C%20%7B%20left%3A%20270%2C%20top%3A%205%20%7D)%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20myMap.geoObjects.add(myPlacemark)%3B%0D%0A%7D%0D%0A%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="<script>" title="<script>" />
</head>
<body>
<table>
<tr><td>
<form method="post">
<select name="konum" id="konum" onchange='this.form.submit()' >
<option value="Seçiniz...">Seçiniz...</option> 
<?php
for($i=0;$i<count($konum)-1;$i++){
?>
<option value="<?php echo $konum[$i];?>"><?php echo $konum[$i];?></option> 
<?php }?>
</select>
</form>
</td><td>
<?php 
}
?>
    <div id="map" style="width:640px; height:400px;"></div>
</td>
</tr>
</table>
</body>
</html>

OnlineDBIslemler Tamamını İndir

package com.example.ali.onlinedbkullanim;

import android.content.Context;
import android.content.DialogInterface;
import android.net.Uri;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;


import org.json.JSONArray;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;

public class MainActivity extends AppCompatActivity implements View.OnClickListener,AdapterView.OnItemClickListener{
    Context c;
    EditText tad,tgun;
    Button btn;
    int[] id;
    String[] ad;
    ListView lv;
    ArrayList<String> liste;
    ArrayAdapter<String> adp;
    AlertDialog.Builder dialog;
    int secilen_id;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        c=this;
        liste=new ArrayList<String>();
        lv=(ListView)findViewById(R.id.list);
        lv.setOnItemClickListener(this);
        adp=new ArrayAdapter<String>(c,android.R.layout.simple_list_item_1,liste);
        lv.setAdapter(adp);
        btn=(Button)findViewById(R.id.btn_ekle);
        btn.setOnClickListener(this);
        tad=(EditText)findViewById(R.id.tad);
        veri_getir();

    }
    public  void post(final Uri.Builder builder)
    {

        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    URL url = new URL("http://alikomesogutlu.com/db.php");
                    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                    conn.setReadTimeout(10000);
                    conn.setConnectTimeout(15000);
                    conn.setRequestMethod("POST");
                    conn.setDoInput(true);
                    conn.setDoOutput(true);

                    String query = builder.build().getEncodedQuery();

                    OutputStream os = conn.getOutputStream();//bağlantının cıkısı
                    BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
                    writer.write(query);
                    writer.flush();
                    writer.close();
                    os.close();

                }
                catch (Exception ex)
                {
                    Log.d("hata",ex.getMessage());
                }
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        veri_getir();
                    }
                });
            }
        }).start();
    }
public void veri_getir()
{
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    URL url = new URL("http://alikomesogutlu.com/db.php");
                    HttpURLConnection conn = (HttpURLConnection) url.openConnection();

                    StringBuilder builder=new StringBuilder();
                    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(conn.getInputStream()));

                    String json="";

                    while ((json = bufferedReader.readLine()) != null)
                        builder.append(json + "\n");

                    JSONArray jsonArray = new JSONArray(builder.toString().trim());
                     id = new int[jsonArray.length()];
                     ad = new String[jsonArray.length()];

                    for (int i = 0; i < jsonArray.length(); i++) {
                        JSONObject obj = jsonArray.getJSONObject(i);

                        id[i] = obj.getInt("id");
                        ad[i]=obj.getString("ad");
                    }
                }
                catch (Exception ex)
                {
                    Log.d("hata",ex.getMessage());
                }
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                     liste.clear();
                     adp.notifyDataSetChanged();
                    for (int i=0;i<id.length;i++)
                        adp.add(ad[i]);
                    }
                });
            }
        }).start();
}
    @Override
    public void onClick(View view) {
        if(tad.getText().length()>0)
        {
            Uri.Builder builder = new Uri.Builder();//post paremetreleri ayarlanıyor
            builder.appendQueryParameter("ad",tad.getText()+"");
            builder.appendQueryParameter("durum", "0");
            post(builder);
            tad.setText("");
        }

    }
    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
        dialog=new AlertDialog.Builder(c);
        tgun=new EditText(c);
        tgun.setText(liste.get(i));
        secilen_id=id[i];
        dialog.setView(tgun);
        dialog.setTitle("Güncelle/Sil");
        dialog.setPositiveButton("Sil", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Uri.Builder builder = new Uri.Builder();//post paremetreleri ayarlanıyor
                builder.appendQueryParameter("id",secilen_id+"");
                builder.appendQueryParameter("durum", "1");
                post(builder);
            }
        });
        dialog.setNegativeButton("Güncelle", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                if(tgun.getText().length()>0) {
                    Uri.Builder builder = new Uri.Builder();//post paremetreleri ayarlanıyor
                    builder.appendQueryParameter("ad", tgun.getText() + "");
                    builder.appendQueryParameter("durum", "2");
                    builder.appendQueryParameter("id", secilen_id + "");
                    post(builder);
                }
                else
                    Toast.makeText(c,"Alan Boş bırakılamaz!!",Toast.LENGTH_LONG).show();
            }
        });
        dialog.create().show();
    }
}
<span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span>
<?php
 function conn(){
	 try{
	 return	$baglanti=new PDO('mysql:host=localhost;port=3306;dbname=Veritabanı ismi;charset=utf8',"Kulanıcı ismi","Şifre");
	}
	catch(PDOException $ex)
	{
		$ex->getMessage();
	}
 }
 
 function insert($ad)
 {
	 try{
		 $baglanti=conn();
	$sorgu1=$baglanti->prepare("insert into kisiler(ad) values(?)");
    $sorgu1->bindParam(1,$ad);
    $sorgu1->execute();
    $baglanti=null;
	}
	catch(PDOException $ex)
	{
		$ex->getMessage();
	}
 }
 function get_data()
 {
	 try{
		 $baglanti=conn();
	$sorgu=$baglanti->prepare("select * from kisiler order by id desc");
    $sorgu->execute();
	$veri=$sorgu->fetchAll(PDO::FETCH_ASSOC);
    $dizi;
	$sayac=0;
	foreach($veri as $deger)
	{
		$dizi[$sayac++]=['id'=>$deger["id"],'ad'=>$deger["ad"]];
	}
	$baglanti=null;
	echo json_encode($dizi);
	}
	catch(PDOException $ex)
	{
		$ex->getMessage();
	}
 }
  function update($ad,$id)
 {
	 try{
		 $baglanti=conn();
	$sorgu1=$baglanti->prepare("update kisiler set ad=? where id=?");
    $sorgu1->bindParam(1,$ad);
	$sorgu1->bindParam(2,$id);
    $sorgu1->execute();
    $baglanti=null;
	}
	catch(PDOException $ex)
	{
		$ex->getMessage();
	}
 }
  function data_delete($id)
 {
	 try{
		 $baglanti=conn();
	$sorgu1=$baglanti->prepare("delete from kisiler where id=?");
	$sorgu1->bindParam(1,$id);
    $sorgu1->execute();
    $baglanti=null;
	}
	catch(PDOException $ex)
	{
		$ex->getMessage();
	}	 
 }
  if(isset($_POST['ad'])&&isset($_POST['durum'])&&$_POST['durum']=='0')
 {
    insert($_POST['ad']);	 
 }
 else if(isset($_POST['id'])&&isset($_POST['durum'])&&$_POST['durum']=='1')
 {
    data_delete($_POST['id']);
 }
 else if(isset($_POST['ad'])&&isset($_POST['id'])&&isset($_POST['durum'])&&$_POST['durum']=='2')
 {
    update($_POST['ad'],$_POST['id']);
 }
 else{
	get_data();
 }
?>

 

package com.example.ali.tabhostkullanm;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TabHost;

public class MainActivity extends AppCompatActivity {
  TabHost tab;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    tab=(TabHost)findViewById(R.id.tab);
    tab.setup();
        TabHost.TabSpec s1=tab.newTabSpec("Sayfa-1");//yeni segmeler olusturuluyor
        TabHost.TabSpec s2=tab.newTabSpec("Sayfa-2");
        TabHost.TabSpec s3=tab.newTabSpec("Sayfa-3");

        s1.setContent(R.id.tab1);//her tabın Linearlayoutu ayarlanıyor
        s2.setContent(R.id.tab2);
        s3.setContent(R.id.tab3);
        s1.setIndicator("Sayfa-1");//gösterge ayarlanıyor
        s2.setIndicator("Sayfa-2");
        s3.setIndicator("Sayfa-2");
        tab.addTab(s1);//sayfalar tabhosta ekleniyor
        tab.addTab(s2);
        tab.addTab(s3);
    }
}
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TabHost
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/tab"
        >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <LinearLayout
                    android:id="@+id/tab1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical">
                  <!-- 1.Sayfa layout'u-->
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/tab2"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical">
                    <!-- 2.Sayfa layout'u-->
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/tab3"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical">
                    <Button
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content" />
                    <!-- 3.Sayfa layout'u-->
                </LinearLayout>

            </FrameLayout>
        </LinearLayout>
    </TabHost>
</android.support.constraint.ConstraintLayout>

 

Hepsini indir

package com.example.ali.myapplication;


import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;


import com.example.ali.myapplication.fragment1.form;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{

  RelativeLayout rl;
  LinearLayout ll;
  Fragment frg;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        PageCreate();
    }

    public void PageCreate()
    {
        rl=(RelativeLayout)findViewById(R.id.cerceve);//layoutu alıyoruz cünkü icersisine ekleme yapmak için
        ll=new LinearLayout(this);
        ll.setOrientation(LinearLayout.VERTICAL);
        ViewGroup.LayoutParams lp=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        ll.setLayoutParams(lp);//genislik ve yükseklik ayarlandi
            Button btn=new Button(this);
            btn.setText("fragment'e geçis");
            int id=1;
            btn.setId(id);
            btn.setOnClickListener(this);
            ll.addView(btn);
            rl.addView(ll);
    }

    @Override
    public void onClick(View view) {
       frg=new form();
        FragmentManager fm=getSupportFragmentManager();//fragment yöneticisi
        FragmentTransaction ft=fm.beginTransaction();//transaction islemi basladı
        ft.replace(rl.getId(),frg);//layoutlar yer degistirdi
        ft.commit();//
    }

}
package com.example.ali.myapplication.fragment1;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import com.example.ali.myapplication.R;

/**
 * A simple {@link Fragment} subclass.
 */
public class form extends Fragment  {
  Button btn;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      final Fragment fgm=this;
      View view=inflater.inflate(R.layout.fragment_form,container,false);//view 'e esitledik componentleri baglamak için
      btn=(Button)view.findViewById(R.id.btn);
      btn.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              getFragmentManager().beginTransaction().remove(fgm).commit();//fragment silindi ve onaylandı
          }
      });
      return view;
    }


}

Puantaj APK indir
Puantaj Uygulaması Kaynak Kodları indir

package com.example.ali.puantajuygulamas;

import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import adepter.adepter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import puantaj.Puantaj;
import veritabani.database;

public class MainActivity extends AppCompatActivity implements View.OnClickListener,AdapterView.OnItemClickListener {
    public Button[] btn;
    public ListView lv;
    public EditText[] et,gun_et;
    static ArrayList<Puantaj> liste;
    DatePickerDialog trh;
    public static adepter adp;
    static Calendar clr;
    static database vt;
    static SQLiteDatabase db;
    static TextView[] genel_text;
    int[] genel_text_id={R.id.topgun,R.id.topmesai};
    public int btnid[]={R.id.btngun,R.id.btnayrinti};
    public int etid[]={R.id.mesai,R.id.not};
    public static int yilid;
    private static  Context context;
    public static    Date date;
    static ArrayList<Integer> id;
    DatePicker dp;
   @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        dp=(DatePicker)findViewById(R.id.tarih);
        vt=new database(this);
        context=this;
        date=new Date();
        id=new ArrayList<Integer>();
        clr=Calendar.getInstance();
        btn=new Button[btnid.length];
        et=new EditText[etid.length];
        gun_et=new EditText[et.length];
        genel_text=new TextView[genel_text_id.length];
        for(int i=0;i<btnid.length;i++)
        {
            btn[i]=(Button)findViewById(btnid[i]);
            if(i<etid.length) {
                et[i] = (EditText) findViewById(etid[i]);
               genel_text[i]=(TextView)findViewById(genel_text_id[i]);
            }
            btn[i].setOnClickListener(this);
        }
        et[0].setText("0");
        liste=new ArrayList<Puantaj>();
        adp=new adepter(this,liste);
        lv=(ListView)findViewById(R.id.list);
        lv.setAdapter(adp);
        datagetir();
        geneltoplam(genel_text,liste);
        lv.setOnItemClickListener(this);
   }
    @Override
    public void onClick(View view) {
     switch (view.getId())
     {
         case R.id.btngun:ekle();break;
         case R.id.btnayrinti:ayrinti();break;
     }
    }
    public static void baglan()
    {
        try {
            vt=new database(context);
            db=vt.getWritableDatabase();
        }catch (Exception ex)
        {
            Toast.makeText(context,ex.getMessage(),Toast.LENGTH_LONG).show();
        }
    }
    public void ayrinti()
    {
       Intent frm=new Intent(this,Main2Activity.class);
       startActivity(frm);
    }
    public static boolean checkdata1()
    {
        try {
            baglan();
            Cursor c=db.rawQuery("select yilid from Yil where yil=?",new String[] {clr.get(Calendar.YEAR)+""});
            c.moveToPosition(-1);
            while(c.moveToNext())
            {
                yilid=c.getInt(0);
                c.close();
                db.close();
                return false;
            }
          c.close();
          db.close();
        }catch (Exception ex)
        {
            Toast.makeText(context,ex.getMessage(),Toast.LENGTH_LONG).show();
        }
        //önceden bu tarih eklenmmemis
        return  true;
    }
    public boolean checkdata2(String gun)
    {  //Aynı gün eklenmesini engelliyoruz
        try {
            baglan();
            Cursor c=db.query("Puantaj",new String[]{"id"},"yilid=? and gun like ?",new String[]{yilid+"",gun+"%"},null,null,null);
            c.moveToPosition(-1);
            while(c.moveToNext())
            {
                c.close();
                db.close();
                return false;
            }
            c.close();
            db.close();
        }catch (Exception ex)
        {
            Toast.makeText(this,ex.getMessage(),Toast.LENGTH_LONG).show();
        }

        return  true;
    }
    public String trh_cevir(int y,int a,int g)
    {  String tarih=y+"";
        if(a<10)
            tarih+="0"+a;
        else
            tarih+=a;
        if(g<10)
            tarih+="0"+g;
        else
            tarih+=g;
 return tarih;
    }
public void ekle()
{
  if(et[0].getText().length()>0) {
    try { //Yıl ve ay ekliyoruz
        double mesai=Double.parseDouble(et[0].getText()+"");
        String tarih=trh_cevir(dp.getYear(),dp.getMonth()+1,dp.getDayOfMonth());
        if (checkdata1()) { //yil ve gün eklenecek
       baglan();
       ContentValues par1=new ContentValues();
       par1.put("yil",clr.get(Calendar.YEAR));
       db.insertOrThrow("Yil",null,par1);
       db.close();
       checkdata1();
            baglan();
            ContentValues par=new ContentValues();
            par.put("gun",tarih);
            par.put("mesai",mesai);
            par.put("yilid",yilid);
            par.put("gunluk",et[1].getText()+"");
            long tran=  db.insertOrThrow("Puantaj",null,par);
            db.close();
            datagetir();
            et[1].setText("");
            et[0].setText("0");
        } else {
            //normal sadece gün ekleniyor
            if(checkdata2(tarih)) {
                baglan();
                ContentValues par = new ContentValues();
                par.put("gun", tarih);
                par.put("mesai", mesai);
                par.put("yilid", yilid);
                par.put("gunluk", et[1].getText() + "");
                long tran = db.insertOrThrow("Puantaj", null, par);
                db.close();
                datagetir();
                et[1].setText("");
                et[0].setText("0");
            }
            else
                Toast.makeText(this,"Aynı Tarih Eklenemez!!!", Toast.LENGTH_LONG).show();
        }
    } catch (Exception ex) {
        Toast.makeText(this, ex.getMessage(), Toast.LENGTH_LONG).show();
    }

}

}

public static void datagetir()
{
    try {
        DateFormat frmt=new SimpleDateFormat("yyyyMM");
        String tarih=frmt.format(date);
        tarih+="%";
        checkdata1();
        baglan();
        Cursor c=db.query("Puantaj",new String[]{"gun","mesai","gunluk","id"},"gun like ? and yilid=?",new String[]{tarih,yilid+""},null,null,"gun ASC");
        liste.clear();
        id.clear();
        adp.notifyDataSetChanged();
        c.moveToPosition(-1);
        while(c.moveToNext())
        {
             String tarih1=c.getString(0);
             String tarih2=tarih1.substring(0,4)+"/";
             tarih2+=tarih1.substring(4,6)+"/";
             tarih2+=tarih1.substring(6,8);
           liste.add(new Puantaj(tarih2,c.getDouble(1),c.getString(2)));
            id.add(c.getInt(3));
        }
        c.close();
        db.close();
        geneltoplam(genel_text,liste);
}catch (Exception ex)
    {
        Toast.makeText(context, ex.getMessage(), Toast.LENGTH_LONG).show();
    }
}
public void guncelle(String gun,String  mesai,String not,int secilen_id)
{    if(gun.length()>0&&mesai.length()>0)//gün ve mesai' yi kontrol ediyoruz
{     double gmesai=Double.parseDouble(mesai);
    try {
        if(checkdata2(gun)) {
            baglan();
            ContentValues par = new ContentValues();
            par.put("gun", gun);
            par.put("mesai", gmesai);
            par.put("gunluk", not);
            db.update("Puantaj", par, "id=?", new String[]{"" + secilen_id});
            db.close();
            datagetir();
        }
        else
        {
            Toast.makeText(this,"Aynı Tarih Güncellenemez ve not veya mesai güncellendi", Toast.LENGTH_LONG).show();
            baglan();
            ContentValues par = new ContentValues();
            par.put("mesai", gmesai);
            par.put("gunluk", not);
            db.update("Puantaj", par, "id=?", new String[]{"" + secilen_id});
            db.close();
            datagetir();
        }


    }catch (Exception ex)
    {
        Toast.makeText(this, ex.getMessage(), Toast.LENGTH_LONG).show();
    }
}
else
    Toast.makeText(this, "Lütfen Değerleri Doğru Giriniz!!!", Toast.LENGTH_LONG).show();
}
//tıklanan notu dialogta gösteriyoruz
public static void notgoster(String not)
{
    if(not.length()>0) {
        LinearLayout layout = new LinearLayout(context);
        TextView tgunluk = new TextView(context);
        tgunluk.setText(not);
        layout.addView(tgunluk);
        AlertDialog.Builder dialog = new AlertDialog.Builder(context);
        dialog.setTitle("NOT");
        dialog.setCancelable(true);
        dialog.setView(layout);
        dialog.create().show();
    }
    else
        Toast.makeText(context,"Bu güne ait herhangi bir not yok!!",Toast.LENGTH_LONG).show();

}
public void sil(int sil_indis)
{
    try {
        baglan();
        db.delete("Puantaj","id=?",new String[]{id.get(sil_indis)+""});
        db.close();
        datagetir();
    }catch (Exception ex)
    {
        Toast.makeText(this, ex.getMessage(), Toast.LENGTH_LONG).show();
    }
}
//toplam gün ve mesai
public static void geneltoplam(TextView[] genel,ArrayList<Puantaj> liste)
{
    String[] ay=Main2Activity.aylar;
    SimpleDateFormat sdf=new SimpleDateFormat("MM");
    final int tarih=Integer.parseInt(sdf.format(date));
    genel[0].setText(ay[tarih-1]+" ay'ı Toplam="+liste.size()+" gün");
    double mesaitop=0.0;
    for(int i=0;i<liste.size();i++)
    {
        Puantaj p=liste.get(i);
        mesaitop+=p.mesai;
    }
   genel[1].setText("Mesai Toplam="+mesaitop+" saat");
}
String secilen_tarih;
   int secilen_indis;
    String[] dt;
   @Override
   //Listview in tıklanma olayı
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
      Puantaj k=liste.get(i);
    final   String[] dt={k.gun.substring(0,4),k.gun.substring(5,7),k.gun.substring(8,10)};
      secilen_tarih=dt[0]+dt[1]+dt[2];
       secilen_indis=i;
       Puantaj p=liste.get(i);
       double mesai=p.mesai;
       String not=p.not;
        LinearLayout layout = new LinearLayout(context);
        layout.setOrientation(LinearLayout.VERTICAL);
        Button btn_tarih=new Button(this);
        btn_tarih.setText("Gün Seçiniz");
        btn_tarih.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                trh=new DatePickerDialog(context, new DatePickerDialog.OnDateSetListener() {
                    @Override
                    public void onDateSet(DatePicker datePicker, int i, int i1, int i2) {
                       secilen_tarih=trh_cevir(i,(i1+1),i2);

                    }
                },Integer.parseInt(dt[0]),Integer.parseInt(dt[1])-1,Integer.parseInt(dt[2]));
                trh.setTitle("Tarih Seciniz");
                trh.setButton(DatePickerDialog.BUTTON_POSITIVE,"Ayarla",trh);
                trh.setButton(DatePickerDialog.BUTTON_NEGATIVE,"Iptal",trh);
                trh.show();
            }
        });
        layout.addView(btn_tarih);
        for(int a=0;a<gun_et.length;a++)
        {
            gun_et[a]=new EditText(this);
           layout.addView(gun_et[a]);
        }
        gun_et[0].setText(mesai+"");
        gun_et[1].setText(not);
        final AlertDialog.Builder dialog = new AlertDialog.Builder(context);
        dialog.setTitle("Düzenle veya Sil");
        dialog.setCancelable(true);
        dialog.setView(layout);
        dialog.setPositiveButton("Düzenle", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                   if(secilen_tarih.length()>0)
                   {
                       guncelle(secilen_tarih,gun_et[0].getText()+"",gun_et[1].getText()+"",id.get(secilen_indis));
                   }
                   else
                       Toast.makeText(getApplicationContext(), "Lütfen Tarihi Seçiniz", Toast.LENGTH_LONG).show();
            }
        });
        dialog.setNegativeButton("Sil", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                     sil(secilen_indis);
            }
        });
        dialog.create().show();
    }
}
package com.example.ali.puantajuygulamas;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import adepter.adepter1;
import puantaj.Puantaj;
import veritabani.*;
import java.io.DataOutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

public class Main2Activity extends AppCompatActivity implements View.OnClickListener{
    public ListView lv;
    public Button btn,btn_sil;
    public Spinner[] sp;
   public int[] sp_id={R.id.syil,R.id.say};
   public ArrayList<String> list[];
    public ArrayList<Integer> id,lvlis_id;
   ArrayList<Puantaj> lvlist;
   public ArrayAdapter<String >[] adp;
   adepter1 myadp;
   database vt;
   SQLiteDatabase db;
    private static Context context;
    RadioButton[] rbtn;
    TextView[] genel_text;
    int[] genel_text_id={R.id.topgun,R.id.topmesai};
   public static String[] aylar={"Ocak","Şubat","Mart","Nisan","Mayıs","Haziran","Temmuz","Ağustos","Eylül","Ekim","Kasım","Aralık"};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        context=this;
        list=new ArrayList[sp_id.length];
        lvlis_id=new ArrayList<Integer>();
       vt=new database(this);
        sp=new Spinner[sp_id.length];
        adp=new ArrayAdapter[list.length];
       id=new ArrayList<Integer>();
        genel_text=new TextView[genel_text_id.length];
        for(int i=0;i<sp.length;i++)
       {
           sp[i]=(Spinner)findViewById(sp_id[i]);
           list[i]=new ArrayList<String>();
           adp[i]=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,list[i]);
           sp[i].setAdapter(adp[i]);
           genel_text[i]=(TextView)findViewById(genel_text_id[i]);
       }
    lvlist=new ArrayList<Puantaj>();
       myadp=new adepter.adepter1(this,lvlist);
       lv=(ListView)findViewById(R.id.liste);
       lv.setAdapter(myadp);
       spdoldur();
       for(int i=0;i<aylar.length;i++)
           adp[1].add(aylar[i]);
       Date date=new Date();
       SimpleDateFormat sdf=new SimpleDateFormat("MM");
       final int tarih=Integer.parseInt(sdf.format(date));
        sp[1].setSelection(tarih-1);
        btn_sil=(Button)findViewById(R.id.btnsil);
        btn_sil.setEnabled(false);
        btn_sil.setOnClickListener(this);
        btn=(Button)findViewById(R.id.btnara);
        btn.setOnClickListener(this);

    }
    public static void notgoster(String not)
    {
        if(not.length()>0) {
            LinearLayout layout = new LinearLayout(context);
            TextView tgunluk = new TextView(context);
            tgunluk.setText(not);
            layout.addView(tgunluk);
            AlertDialog.Builder dialog = new AlertDialog.Builder(context);
            dialog.setTitle("NOT");
            dialog.setCancelable(true);
            dialog.setView(layout);
            dialog.create().show();
        }
        else
            Toast.makeText(context,"Bu güne ait herhangi bir not yok!!",Toast.LENGTH_LONG).show();

    }
public void baglan()
{
    try
    {
   db=vt.getWritableDatabase();
    }
    catch (Exception ex)
    {
        Toast.makeText(this,ex.getMessage(), Toast.LENGTH_LONG).show();
    }
}
public void spdoldur()
{
    try
    {
       list[0].clear();
       adp[0].notifyDataSetChanged();
       id.clear();
        baglan();
        Cursor c=db.query("Yil",new String[]{"yilid","yil"},null,null,null,null,null);
        c.moveToPosition(-1);
        while(c.moveToNext())
        {
            adp[0].add(c.getString(1));
            id.add(c.getInt(0));
        }
        c.close();
        db.close();
    }
    catch (Exception ex)
    {
        Toast.makeText(this,ex.getMessage(), Toast.LENGTH_LONG).show();
    }
}

    @Override
    public void onClick(View view) {
        switch (view.getId())
        {
            case R.id.btnara:ara();break;
            case R.id.btnsil:hepsinisil();break;
        }
    }
    public void ara()
    {
        int secilen_yil=sp[0].getSelectedItemPosition();
        int secilen_ay=sp[1].getSelectedItemPosition();
        if(secilen_ay>-1&&secilen_yil>-1)
            try
            {
                String tarih_query=(secilen_ay+1)+"";
                if(tarih_query.length()<2)
                    tarih_query="0"+tarih_query;
                tarih_query=adp[0].getItem(secilen_yil)+tarih_query+"%";
                lvlist.clear();
                lvlis_id.clear();
                myadp.notifyDataSetChanged();
                baglan();
                Cursor c=db.query("Puantaj",new String[]{"gun","mesai","gunluk","id"},"yilid=? and gun like ?",new String[]{id.get(secilen_yil)+"",tarih_query},null,null,"gun ASC");
                c.moveToPosition(-1);
                while(c.moveToNext())
                {   String tarih1=c.getString(0);
                    String tarih3=tarih1.substring(0,4)+"/";
                    tarih3+=tarih1.substring(4,6)+"/";
                    tarih3+=tarih1.substring(6,8);
                    lvlist.add(new Puantaj(tarih3,c.getDouble(1),c.getString(2)));
                    lvlis_id.add(c.getInt(3));
                }
                c.close();
                db.close();
                if(lvlist.size()!=0)
                    btn_sil.setEnabled(true);
                else
                    btn_sil.setEnabled(false);
                MainActivity.geneltoplam(genel_text,lvlist);
            }
            catch (Exception ex)
            {
                Toast.makeText(getApplicationContext(),ex.getMessage(), Toast.LENGTH_LONG).show();
            }
    }
    public void hepsinisil()
    {   final AlertDialog.Builder dialog=new AlertDialog.Builder(this);
         dialog.setTitle("Seçim");
         dialog.setCancelable(false);
        LinearLayout layout=new LinearLayout(this);
       layout.setOrientation(LinearLayout.VERTICAL);
        final RadioGroup grup=new RadioGroup(this);
        final RadioButton[] rbtn={new RadioButton(this),new RadioButton(this)};
        rbtn[0].setText(list[0].get(sp[0].getSelectedItemPosition()));
        rbtn[1].setText(list[1].get(sp[1].getSelectedItemPosition()));
        grup.addView(rbtn[0]);
        grup.addView(rbtn[1]);
        layout.addView(grup);
        dialog.setView(layout);
        dialog.setPositiveButton("Hepsini Sil", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                int secilen_yil=sp[0].getSelectedItemPosition();
                int secilen_ay=sp[1].getSelectedItemPosition();
                if(secilen_ay>-1&&secilen_yil>-1) {
                    try {
                         int secilen_id=grup.getCheckedRadioButtonId();
                        if (secilen_id==rbtn[0].getId())//Yıl'a göre hepsini silme
                        {
                            baglan();
                            db.delete("Puantaj","yilid=?",new String[]{id.get(secilen_yil)+""});
                            db.close();
                            MainActivity.datagetir();
                            spdoldur();
                            ara();
                        }
                        else if(secilen_id==rbtn[1].getId())//Secili yıl'ın bu hesini silme
                        {
                            baglan();
                            for(int a=0;a<lvlis_id.size();a++)
                                db.delete("Puantaj","id=? and yilid=?",new String[]{lvlis_id.get(a)+"",id.get(secilen_yil)+""});
                            db.close();
                            MainActivity.datagetir();
                            ara();
                        }
                        else
                            Toast.makeText(getApplicationContext(),"Hiçbir secim yapılmadı!!",Toast.LENGTH_SHORT).show();
                    } catch (Exception ex) {

                    }
                }
            }
        });
        dialog.setNegativeButton("Vazgeç", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {

            }
        });
    dialog.create().show();
    }
}
<span data-mce-type="bookmark" style="display: inline-block; width: 0px; overflow: hidden; line-height: 0;" class="mce_SELRES_start"></span>