Notes
![]() ![]() Notes - notes.io |
(MAİN ACTİVTY)
https://i.hizliresim.com/Ll99vG.png
package com.example.xcode.telefonrehberi;
import android.content.ContentValues;
import android.content.DialogInterface;
import android.content.Intent;
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.Button;
import android.widget.EditText;
import android.widget.Toast;
import static com.example.xcode.telefonrehberi.R.*;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
Button ekle, oku, sil, temizle,listele, tumSil,guncelle, okuE;
EditText ad, tel, mail, etID;
String ad1, tel1, mail1, id1;
VeriTabanı vt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ad=findViewById(R.id.etIsim);
tel=findViewById(R.id.etTel);
mail = findViewById(R.id.etMail);
etID=findViewById(R.id.etID);
vt=new VeriTabanı(this);
ekle=findViewById(R.id.btnEkle);
oku=findViewById(R.id.btnOku);
sil=findViewById(R.id.btnSil);
tumSil=findViewById(id.btnTumSil);
tumSil.setOnClickListener(this);
temizle=findViewById(R.id.btnTemizle);
listele=findViewById(R.id.btnListele);
ekle.setOnClickListener(this);
oku.setOnClickListener(this);
sil.setOnClickListener(this);
temizle.setOnClickListener(this);
listele.setOnClickListener(this);
guncelle=findViewById(id.btnGuncelle);
guncelle.setOnClickListener(this);
okuE=findViewById(id.btnOkuE);
okuE.setOnClickListener(this);
}
@Override
public void onClick(View view) {
ContentValues cv =new ContentValues();
SQLiteDatabase db=vt.getWritableDatabase();
String secim=null;
String[] secimAra=null;
switch (view.getId()){
case id.btnEkle:
Toast.makeText(this, "Kayıt Eklenecek", Toast.LENGTH_SHORT).show();
cv.put("isim",ad.getText().toString());
cv.put("tel_no",tel.getText().toString());
cv.put("email",mail.getText().toString());
long rowID=db.insert("kayit", null,cv);
Toast.makeText(this, rowID+" nolu kayıt yapıldı", Toast.LENGTH_SHORT).show();
break;
case R.id.btnOku:
String isim1=ad.getText().toString();
String tel_no1=tel.getText().toString();
String email1=mail.getText().toString();
String etID1=etID.getText().toString();
if(etID1.length()!=0){
secim="id= ?";
secimAra= new String[]{etID1};
} else
if(isim1.length()!=0){
secim="isim= ?";
secimAra= new String[]{isim1};
} else
if(tel_no1.length()!=0){
secim="tel_no= ?";
secimAra= new String[]{tel_no1};
} else
if(email1.length()!=0){
secim="email= ?";
secimAra= new String[]{email1};
}
Cursor c=db.query("this",null,secim,secimAra,null,null,null);
if(c.moveToFirst()){
int siraindex=c.getColumnIndex("id");
Toast.makeText(this, "sıra no"+siraindex, Toast.LENGTH_SHORT).show();
id1=c.getString(siraindex);
int adindex=c.getColumnIndex("isim");
ad1=c.getString(adindex);
int telindex=c.getColumnIndex("tel_no");
tel1=c.getString(telindex);
int mailindex=c.getColumnIndex("email");
mail1=c.getString(mailindex);
Intent intent =new Intent(MainActivity.this,Goruntule.class);
intent.putExtra("id",id1);
intent.putExtra("ad",ad1);
intent.putExtra("tel",tel1);
intent.putExtra("mail",mail1);
startActivity(intent);
}
break;
case R.id.btnTemizle: etID.setText(null); ad.setText(null);
tel.setText(null);mail.setText(null);
break;
//id si verilen kaydı sil
case R.id.btnSil:
id1=etID.getText().toString();
int silSiraNo=db.delete("kayit","id = "+id1,null );
if (silSiraNo==0)
Toast.makeText(this," aranan kayit dosyada yok", Toast.LENGTH_SHORT).show();
else Toast.makeText(this, id1+ " nolu kayit silindi", Toast.LENGTH_SHORT).show();
break;
//dosyadaki tüm kayıtları sil
case R.id.btnTumSil:
int silinenKayit = db.delete("kayit",null,null);
Toast.makeText(this, silinenKayit+" kayıt silindi", Toast.LENGTH_SHORT).show();
break;
case R.id.btnOkuE:
isim1=ad.getText().toString();
tel_no1=tel.getText().toString();
email1=mail.getText().toString();
etID1=etID.getText().toString();
if(etID1.length()!=0){
secim="id= ?";
secimAra= new String[]{etID1};
} else
if(isim1.length()!=0){
secim="isim= ?";
secimAra= new String[]{isim1};
} else
if(tel_no1.length()!=0){
secim="tel_no= ?";
secimAra= new String[]{tel_no1};
} else
if(email1.length()!=0){
secim="email= ?";
secimAra= new String[]{email1};
}
c=db.query("this",null,secim,secimAra,null,null,null);
if(c.moveToFirst()) {
int siraindex = c.getColumnIndex("id");
Toast.makeText(this, "sıra no" + siraindex, Toast.LENGTH_SHORT).show();
id1 = c.getString(siraindex);
int adindex = c.getColumnIndex("isim");
ad1 = c.getString(adindex);
int telindex = c.getColumnIndex("tel_no");
tel1 = c.getString(telindex);
int mailindex = c.getColumnIndex("email");
mail1 = c.getString(mailindex);
etID.setText(id1);
ad.setText(ad1);
tel.setText(tel1);
mail.setText(mail1);
}
break;
case R.id.btnGuncelle:
cv.put("isim",ad.getText().toString());
cv.put("tel_no",tel.getText().toString());
cv.put("email",mail.getText().toString());
long ID=db.update("kayit",cv, "id",null);
Toast.makeText(this, ID+" nolu kayıt güncelle", Toast.LENGTH_SHORT).show();
break;
case R.id.btnListele:
Intent i= new Intent(MainActivity.this, Listeleme.class) ;
startActivity(i);
break;
}
}
}
(GÖRÜNTLE AVTİVTY)
https://i.hizliresim.com/WqJJo2.png
package com.example.xcode.telefonrehberi;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;
public class Goruntule extends AppCompatActivity {
TextView tvId, tvAd, tvTel, tvMail;
ImageButton ibArama, ibSms, ibMail;
String ad,tel,mail;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_goruntule);
tvAd=findViewById(R.id.tvAd);
tvMail=findViewById(R.id.tvMail);
tvId=findViewById(R.id.tvId);
tvTel=findViewById(R.id.tvTel);
Intent intent = getIntent();
ibArama=findViewById(R.id.ibArama);
ibSms=findViewById(R.id.ibSms);
ibMail=findViewById(R.id.ibMail);
ad=intent.getStringExtra("ad");
tel=intent.getStringExtra("tel");
mail=intent.getStringExtra("mail");
tvId.setText(intent.getStringExtra("id"));
tvAd.setText(ad);
tvTel.setText(tel);
tvMail.setText(mail);
ibArama.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent araIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("tel:"+tel));
startActivity(araIntent);
}
});
ibSms.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent mesajIntent=new Intent(Intent.ACTION_VIEW);
mesajIntent.setData(Uri.parse("sms: " +tel));
startActivity(mesajIntent);
}
});
ibMail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent mailIntent = new Intent(Intent.ACTION_SEND);
mailIntent.setType("plain/text");
String mailList[]={mail};
mailIntent.putExtra(Intent.EXTRA_EMAIL,mailList);
startActivity(mailIntent);
}
});
}
}
(VERİTABANI)
package com.example.xcode.telefonrehberi;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class VeriTabanı extends SQLiteOpenHelper {
public VeriTabanı(Context context) {
super(context,"adres_defteri",null,1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table kayit(id integer primary key autoincrement," +
"isim text,tel_no text,email text);");
}
@Override
public void onUpgrade(SQLiteDatabase db, int i, int i1) {
}
}
(LİSTELEME ACTİVTY)
https://i.hizliresim.com/4j66p4.png
package com.example.xcode.telefonrehberi;
import android.app.FragmentManager;
import android.content.Intent;
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.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import java.util.ArrayList;
public class Listeleme extends AppCompatActivity implements View.OnClickListener{
Button btnİsim,btnMail,btnTel;
ListView lvRehber;
VeriTabanı vt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_listeleme);
lvRehber=findViewById(R.id.lvRehber);
btnİsim=findViewById(R.id.btnİsim);
btnİsim.setOnClickListener(this);
btnMail=findViewById(R.id.btnMail);
btnMail.setOnClickListener(this);
btnTel=findViewById(R.id.btnTel);
btnTel.setOnClickListener(this);
vt = new VeriTabanı(this);
}
@Override
public void onClick(View v) {
SQLiteDatabase db=vt.getWritableDatabase();
String orderBy= null;
Cursor cursor= null;
switch (v.getId()) {
case R.id.btnİsim: orderBy = "isim";break;
case R.id.btnTel: orderBy = "tel_no";break;
case R.id.btnMail: orderBy = "email";break;
}
String ad,mail,tel;
int id1;
cursor = db.query("kayit",null,null,null,null,null,orderBy);
final ArrayList<String> txt = new ArrayList<String>();
while (cursor.moveToNext()){
ad=cursor.getString(cursor.getColumnIndex( "isim"));
id1=cursor.getInt(cursor.getColumnIndex( "id"));
tel=cursor.getString(cursor.getColumnIndex( "tel_no"));
mail=cursor.getString(cursor.getColumnIndex( "email"));
txt.add(id1+ "t" + ad +"t" + tel + "t" + mail);
}
cursor.close();
db.close();
ArrayAdapter<String> veriAdaptoru = new ArrayAdapter<String>
(this,android.R.layout.simple_list_item_1,android.R.id.text1,txt);
lvRehber.setAdapter(veriAdaptoru);
lvRehber.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String []veri=txt.get(i).split("t");
Intent ıntent=new Intent(Listeleme.this,Goruntule.class);
ıntent.putExtra("id",veri[0]);
ıntent.putExtra("ad",veri[1]);
ıntent.putExtra("tel",veri[2]);
ıntent.putExtra("mail",veri[3]);
startActivity(ıntent);
}
});
}
}
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team