NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

---VERİTABANI-------
public class VeriTabani extends SQLiteOpenHelper{
public VeriTabani(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 sqLiteDatabase, int i, int i1) {

}
}
-------------MAIN ACTİVİTY-------------
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
Button ekle,sil,oku,liste,temizle,tumSil,btnGuncelle,btnOkuE;
EditText ad,tel,mail,etID;
VeriTabani vt;
String ad1,tel1,mail1,id1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ad = findViewById(R.id.etIsim);
tel = findViewById(R.id.etTelno);
mail = findViewById(R.id.etMail);
etID = findViewById(R.id.etId);
tumSil = findViewById(R.id.btnTümSil);
sil = findViewById(R.id.btnSil);
btnOkuE=findViewById(R.id.btnOkuE);



btnGuncelle = findViewById(R.id.Guncelle);

vt = new VeriTabani(this);

ekle = findViewById(R.id.btnEkle);
sil = findViewById(R.id.btnSil);
liste = findViewById(R.id.btnListe);
oku = findViewById(R.id.btnOku);
temizle = findViewById(R.id.btnTemizle);

ekle.setOnClickListener(this);
liste.setOnClickListener(this);
oku.setOnClickListener(this);
temizle.setOnClickListener(this);
sil.setOnClickListener(this);
tumSil.setOnClickListener(this);
btnGuncelle.setOnClickListener(this);
btnOkuE.setOnClickListener(this);
}

@Override
public void onClick(View v) {
ContentValues cv = new ContentValues();
SQLiteDatabase db = vt.getWritableDatabase();
String secim = null;
String[] secimAra = null;

switch (v.getId())
{
case R.id.btnEkle:
Toast.makeText(this, "Kayit 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 kayit yapildi...", Toast.LENGTH_SHORT).show();
break;

case R.id.btnOku:
String isim = ad.getText().toString();
String tel_no = tel.getText().toString();
String email = mail.getText().toString();
String id = etID.getText().toString();

if (id.length()!=0)
{
secim="id= ?";
secimAra = new String[]{id};
}
else
if (isim.length()!=0)
{
secim="isim= ?";
secimAra = new String[]{isim};
}
if (tel_no.length()!=0)
{
secim="tel_no= ?";
secimAra = new String[]{tel_no};
}
if (email.length()!=0)
{
secim="email= ?";
secimAra = new String[]{email};
}


if (isim.length()!=0)
{
secim="isim= ?";
secimAra = new String[]{isim};
}
Cursor cursor = db.query("kayit",null,secim,secimAra,null,null,null);
if (cursor.moveToFirst())
{
int siraindex = cursor.getColumnIndex("id");
Toast.makeText(this, "sira no: "+siraindex, Toast.LENGTH_SHORT).show();
id1 = cursor.getString(siraindex);

int adindex = cursor.getColumnIndex("isim");
Toast.makeText(this, "isim: "+adindex, Toast.LENGTH_SHORT).show();
ad1 = cursor.getString(adindex);

int telindex = cursor.getColumnIndex("tel_no");
Toast.makeText(this, "tel no: "+telindex, Toast.LENGTH_SHORT).show();
tel1 = cursor.getString(telindex);

int mailindex = cursor.getColumnIndex("email");
Toast.makeText(this, "mail :"+mailindex, Toast.LENGTH_SHORT).show();
mail1 = cursor.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;


case R.id.btnSil:
id1 = etID.getText().toString();
int teksilinen = db.delete("kayit","id ="+id1,null);
if (teksilinen == 0)
{

Toast.makeText(this, teksilinen + "Aranan Kayıt Dosyada Bulunamadı", Toast.LENGTH_SHORT).show();
}

Toast.makeText(this, teksilinen + "Kayıt Silindi", Toast.LENGTH_SHORT).show();


break;



case R.id.btnTümSil:
int silinenKayit = db.delete("kayit",null,null);
Toast.makeText(this, silinenKayit+"Kayıt Silindi", Toast.LENGTH_SHORT).show();
break;


case R.id.Guncelle:



cv.put("isim",ad.getText().toString());
cv.put("tel_no",tel.getText().toString());
cv.put("email",mail.getText().toString());
int sonuc = db.update("kayit", cv, "id", null);
Toast.makeText(this, sonuc+"Nolu kayıt Guncellendi", Toast.LENGTH_SHORT).show();
break;



case R.id.btnListe:

Intent intent = new Intent(MainActivity.this,ListelemeActivity.class);
startActivity(intent);
break;



case R.id.btnOkuE:

isim = ad.getText().toString();
tel_no = tel.getText().toString();
email = mail.getText().toString();
id = etID.getText().toString();

if (id.length()!=0)
{
secim="id= ?";
secimAra = new String[]{id};
}
else
if (isim.length()!=0)
{
secim="isim= ?";
secimAra = new String[]{isim};
}
if (tel_no.length()!=0)
{
secim="tel_no= ?";
secimAra = new String[]{tel_no};
}
if (email.length()!=0)
{
secim="email= ?";
secimAra = new String[]{email};
}


if (isim.length()!=0)
{
secim="isim= ?";
secimAra = new String[]{isim};
}

cursor = db.query("kayit",null,secim,secimAra,null,null,null);
if (cursor.moveToFirst()) {
int siraindex = cursor.getColumnIndex("id");
Toast.makeText(this, "sira no: " + siraindex, Toast.LENGTH_SHORT).show();
id1 = cursor.getString(siraindex);

int adindex = cursor.getColumnIndex("isim");
Toast.makeText(this, "isim: " + adindex, Toast.LENGTH_SHORT).show();
ad1 = cursor.getString(adindex);

int telindex = cursor.getColumnIndex("tel_no");
Toast.makeText(this, "tel no: " + telindex, Toast.LENGTH_SHORT).show();
tel1 = cursor.getString(telindex);

int mailindex = cursor.getColumnIndex("email");
Toast.makeText(this, "mail :" + mailindex, Toast.LENGTH_SHORT).show();
mail1 = cursor.getString(mailindex);

etID.setText(id1);
ad.setText(ad1);
tel.setText(tel1);
mail.setText(mail1);





}

}
}
}

     
 
what is notes.io
 

Notes.io is a web-based application for 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 12 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

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.