NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io


-------------------------------- HOCA ORNEK -------------
@Override
public void onClick(View v) {
ContentValues cv = new ContentValues();
SQLiteDatabase db = vt.getWritableDatabase();//SQLiteDatabase sınıfında yazılabilir bağlantı açıyoruz.
String secim = null;
String[] secimAra = null;
switch (v.getId())
{
case R.id.btnEkle: // VERİ EKLEME INSERT
Toast.makeText(this, "Kayıt Ekleme İşlemi", Toast.LENGTH_SHORT).show();
cv.put("isim",ad.getText().toString()); // parametre alarak ekleme işlemi
cv.put("tel_no",tel.getText().toString());
cv.put("email",mail.getText().toString());
long rowID = db.insert("kayit",null,cv); // long tutulur degisken
if(rowID > -1)
{
Toast.makeText(this, rowID+" nolu kayit yapildi...", Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(this, "Ekleme İşlemi Başarısız", 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"); //veritabandaki karsılıkları
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: // VERİ SİLME DELETE REMOVE
id1 = etID.getText().toString();
int tekSilinen = db.delete("kayit","id ="+id1,null);

if (tekSilinen == 0)
{
Toast.makeText(this, tekSilinen+"Aranan Kayit Bulunamadı", Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(this, tekSilinen+"Kayıt Silindi", Toast.LENGTH_SHORT).show();
}
break;

case R.id.Guncelle:
id1 = etID.getText().toString();
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,id1,null);
Toast.makeText(this, sonuc +" Nolu Kayıt Güncellendi", 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.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);

break;
}

}

}
}
----------------- GORUNTULE----------------
public class Goruntule extends AppCompatActivity {
TextView id,ad,tel,mail;
String id1,ad1,tel1,mail1;
ImageButton ibArama,ibSms,ibMail;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_goruntule);
id = findViewById(R.id.tvID);
ad = findViewById(R.id.tvAd);
tel = findViewById(R.id.tvTel);
mail = findViewById(R.id.tvMail);
ibArama = findViewById(R.id.ibArama);
ibMail = findViewById(R.id.ibMail);
Intent intent = getIntent();
ad1 = intent.getStringExtra("ad").toString();
tel1 = intent.getStringExtra("tel");
mail1 = intent.getStringExtra("mail");
id.setText(intent.getStringExtra("id"));
ad.setText(intent.getStringExtra("ad"));
tel.setText(intent.getStringExtra("tel"));
mail.setText(intent.getStringExtra("mail"));
}
}
------------------ LİSTELE -------------
Button btnIsim,btnMail,btnTel;
ListView lvRehber;
VeriTabani vt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_listeleme);
lvRehber = findViewById(R.id.lvRehber);
btnIsim = findViewById(R.id.btnisim);
btnIsim.setOnClickListener(this);
btnMail = findViewById(R.id.btnEmail);
btnMail.setOnClickListener(this);
btnTel = findViewById(R.id.btnTelefon);
btnTel.setOnClickListener(this);
vt = new VeriTabani(this);
}

@Override
public void onClick(View view) {
SQLiteDatabase db = vt.getWritableDatabase();
String colums[] = null;
String orderBy=null;
Cursor cursor = null;

switch (view.getId())
{
case R.id.btnisim : orderBy = "isim"; break;
case R.id.btnTelefon : orderBy = "tel_no"; break;
case R.id.btnEmail : 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<?> adapterView, View view, int i, long l) {
String [] veri = txt.get(i).split("t");
Intent intent = new Intent(ListelemeActivity.this,Goruntule.class);
intent.putExtra("id",veri[0]);
intent.putExtra("ad",veri[1]);
intent.putExtra("tel",veri[2]);
intent.putExtra("mail",veri[3]);
startActivity(intent);

}
});

}
}



     
 
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.