NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:text="ID:" />
<EditText
android:id="@+id/etNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:inputType="number" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:text="Name:" />
<EditText
android:id="@+id/etName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:text="Phone number:" />
<EditText
android:id="@+id/etPhone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:inputType="number" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:text="Email:" />
<EditText
android:id="@+id/etEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/addBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ADD" />
<Button
android:id="@+id/readBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Read" />
<Button
android:id="@+id/deleteBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Delete" />
<Button
android:id="@+id/readShowBTn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/clearBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Clear" />
<Button
android:id="@+id/listBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="List" />
<Button
android:id="@+id/deleteAllBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Del All " />
<Button
android:id="@+id/updateBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Update" />
</LinearLayout>
</LinearLayout>
import android.content.ContentValues;
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;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
Button add, read, delete, clear, list, deleteAll, update, readShow;
EditText name, phone, mail, number;
String nameStr, phoneStr, mailStr, numberStr;
VeriTabani vt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
name = findViewById(R.id.etName);
phone = findViewById(R.id.etPhone);
mail = findViewById(R.id.etEmail);
number = findViewById(R.id.etNumber);
vt = new VeriTabani(this);
add = findViewById(R.id.addBtn);
read = findViewById(R.id.readBtn);
delete = findViewById(R.id.deleteBtn);
clear = findViewById(R.id.clearBtn);
list = findViewById(R.id.listBtn);
deleteAll = findViewById(R.id.deleteAllBtn);
update = findViewById(R.id.updateBtn);
readShow = findViewById(R.id.readShowBTn);
add.setOnClickListener(this);
read.setOnClickListener(this);
delete.setOnClickListener(this);
clear.setOnClickListener(this);
list.setOnClickListener(this);
deleteAll.setOnClickListener(this);
update.setOnClickListener(this);
readShow.setOnClickListener(this);
}
@Override
public void onClick(View view) {
ContentValues contentValues = new ContentValues();
SQLiteDatabase sqLiteDatabase = vt.getWritableDatabase(); String secim =
null;
String secimAra[] = null;
switch (view.getId()) {
case R.id.addBtn:
contentValues.put("ISIM", name.getText().toString());
contentValues.put("TEL_NO", phone.getText().toString());
contentValues.put("EMAIL", mail.getText().toString());
long rowID = sqLiteDatabase.insert("KAYIT", null, contentValues);
Toast.makeText(this, ":" + rowID + "nolu kayıt yapıldı",
Toast.LENGTH_SHORT).show();
break;
case R.id.readBtn:
String snameStr = name.getText().toString();
String sphoneStr = phone.getText().toString();
String smailStr = mail.getText().toString();
String snumberStr = number.getText().toString();
if (snumberStr.length() != 0) {
secim = "ID= ?";
secimAra = new String[]{snumberStr};
} else if (snameStr.length() != 0) {
secim = "ISIM= ?";
secimAra = new String[]{snameStr};
} else if (sphoneStr.length() != 0) {
secim = "TEL_NO= ?";
secimAra = new String[]{sphoneStr};
} else if (smailStr.length() != 0) {
secim = "EMAIL= ?";
secimAra = new String[]{smailStr};
}
Cursor cursor = sqLiteDatabase.query("KAYIT", null, secim, secimAra, null,
null, null);
if (cursor.moveToFirst()) {
int siraIndex = cursor.getColumnIndex("ID");
Toast.makeText(this, "id: " + siraIndex, Toast.LENGTH_SHORT).show();
numberStr = cursor.getString(siraIndex);
int adIndex = cursor.getColumnIndex("ISIM");
nameStr = cursor.getString(adIndex);
int telIndex = cursor.getColumnIndex("TEL_NO");
phoneStr = cursor.getString(telIndex);
int mailIndex = cursor.getColumnIndex("EMAIL");
mailStr = cursor.getString(mailIndex);
Intent sendData = new Intent(getApplicationContext(), ResultActivity.class);
sendData.putExtra("ID", numberStr);
sendData.putExtra("ISIM", nameStr);
sendData.putExtra("TEL_NO", phoneStr);
sendData.putExtra("EMAIL", mailStr);
startActivity(sendData);
}
break;
case R.id.deleteBtn:
snumberStr = number.getText().toString();
int silSiraNo = sqLiteDatabase.delete("KAYIT", "ID = " + numberStr, null);
if (silSiraNo == 0)
Toast.makeText(this, "Aranan kayıt dosyada yok.",
Toast.LENGTH_SHORT).show();
else
Toast.makeText(this, snumberStr + "nolu kayıt silindi",
Toast.LENGTH_SHORT).show();
break;
case R.id.clearBtn:
number.setText(null);
name.setText(null);
phone.setText(null);
mail.setText(null);
break;
case R.id.listBtn:
Intent listIntent= new Intent(getApplicationContext(),ListelemeActivity.class);
startActivity(listIntent);
break;
case R.id.deleteAllBtn:
int silinenKayit = sqLiteDatabase.delete("KAYIT", null, null);
Toast.makeText(this, "Silinen kayıt sayısı: " + silinenKayit,
Toast.LENGTH_SHORT).show();
break;
case R.id.readShowBTn:
snameStr = name.getText().toString();
sphoneStr = phone.getText().toString();
smailStr = mail.getText().toString();
snumberStr = number.getText().toString();
if (snumberStr.length() != 0) {
secim = "ID= ?";
secimAra = new String[]{snumberStr};
} else if (snameStr.length() != 0) {
secim = "ISIM= ?";
secimAra = new String[]{snameStr};
} else if (sphoneStr.length() != 0) {
secim = "TEL_NO= ?";
secimAra = new String[]{sphoneStr};
} else if (smailStr.length() != 0) {
secim = "EMAIL= ?";
secimAra = new String[]{smailStr};
}
cursor = sqLiteDatabase.query("KAYIT", null, secim, secimAra, null, null, null);
if (cursor.moveToFirst()) {
int siraIndex = cursor.getColumnIndex("ID");
Toast.makeText(this, "id: " + siraIndex, Toast.LENGTH_SHORT).show();
numberStr = cursor.getString(siraIndex);
int adIndex = cursor.getColumnIndex("ISIM");
nameStr = cursor.getString(adIndex);
int telIndex = cursor.getColumnIndex("TEL_NO");
phoneStr = cursor.getString(telIndex);
int mailIndex = cursor.getColumnIndex("EMAIL");
mailStr = cursor.getString(mailIndex);
number.setText(numberStr);
name.setText(nameStr);
mail.setText(mailStr);
phone.setText(phoneStr);
}
break;
case R.id.updateBtn:
break;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_margin="16dp"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ResultActivity">
<TextView
android:id="@+id/tvID"
android:textColor="@color/colorPrimaryDark"
android:textSize="20dp"
android:layout_margin="16dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tvName"
android:textColor="@color/colorPrimaryDark"
android:textSize="20dp"
android:layout_margin="16dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tvPhone"
android:textColor="@color/colorPrimaryDark"
android:textSize="20dp"
android:layout_margin="16dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tvMail"
android:textColor="@color/colorPrimaryDark"
android:textSize="20dp"
android:layout_margin="16dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageButton
android:id="@+id/callImgBtn"
android:src="@drawable/ic_call_black_24dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageButton
android:id="@+id/mailImgBtn"
android:src="@drawable/ic_drafts_black_24dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageButton
android:id="@+id/smsImgBtn"
android:src="@drawable/ic_sms_black_24dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
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 ResultActivity extends AppCompatActivity {
TextView tvID, tvName, tvPhone,tvMail;
ImageButton call,sms,mail;
String strName, strPhone, strEmail;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_result);
tvID = findViewById(R.id.tvID);
tvName = findViewById(R.id.tvName);
tvPhone = findViewById(R.id.tvPhone);
tvMail = findViewById(R.id.tvMail);
call = findViewById(R.id.callImgBtn);
sms = findViewById(R.id.smsImgBtn);
mail = findViewById(R.id.mailImgBtn);
Intent intent = getIntent();
tvID.setText(intent.getStringExtra("ID"));
strName = intent.getStringExtra("ISIM");
strEmail = intent.getStringExtra("EMAIL");
strPhone = intent.getStringExtra("TEL_NO");
tvName.setText(strName);
tvMail.setText(strEmail);
tvPhone.setText(strPhone);
call.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent callIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("tel:
"+strPhone));
startActivity(callIntent);
}
});
sms.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent smsIntent = new Intent(Intent.ACTION_VIEW);
smsIntent.setData(Uri.parse("sms: "+strPhone));
startActivity(smsIntent);
}
});
mail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent mailIntent = new Intent(Intent.ACTION_SEND);
mailIntent.setType("plain/text");
String mailList[] = {strEmail};
mailIntent.putExtra(Intent.EXTRA_EMAIL,mailList);
startActivity(mailIntent);
}
});
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:orientation="vertical"
android:layout_margin="16dp"
tools:context=".ListelemeActivity">
<TextView
android:id="@+id/siralaBtn"
android:layout_margin="16dp"
android:text=" Sırala"
android:background="#9726"
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="30dp" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/isimSiralaBtn"
android:layout_margin="8dp"
android:text="İSİM"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/telefonSiralaBtn"
android:layout_margin="8dp"
android:text="TELEFON"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/mailSiralaBtn"
android:layout_margin="8dp"
android:text="MAİL"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<ListView
android:id="@+id/listViewRehber"
android:layout_margin="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"></ListView>
</LinearLayout>
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 ListelemeActivity extends AppCompatActivity implements
View.OnClickListener {
Button isimBtn,telefonBtn,mailBtn;
ListView rehber;
VeriTabani vt;
String ad,mail,tel;
String nameStr, phoneStr, mailStr, numberStr;
int id1;
ArrayList<String> txt = new ArrayList<String>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_listeleme);
rehber = findViewById(R.id.listViewRehber);
isimBtn = findViewById(R.id.isimSiralaBtn);
isimBtn.setOnClickListener(this);
telefonBtn = findViewById(R.id.telefonSiralaBtn);
telefonBtn.setOnClickListener(this);
mailBtn = findViewById(R.id.mailSiralaBtn);
mailBtn.setOnClickListener(this);
vt = new VeriTabani(this);
}
@Override
public void onClick(View view) {
SQLiteDatabase db = vt.getWritableDatabase();
String orderBy = null;
Cursor cursor = null;
switch(view.getId())
{
case R.id.isimSiralaBtn: orderBy = "ISIM"; break;
case R.id.telefonSiralaBtn: orderBy = "TEL_NO"; break;
case R.id.mailSiralaBtn: orderBy = "EMAIL" ; break;
}
cursor = db.query("KAYIT",null,null,null,null,null,orderBy);
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> veriAdapter = new
ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,android.R.id.text1,txt);
rehber.setAdapter(veriAdapter);
rehber.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
String[] veri = txt.get(i).split("t");
Intent sendData = new Intent(getApplicationContext(), ResultActivity.class);
sendData.putExtra("ID", veri[0]);
sendData.putExtra("ISIM", veri[1]);
sendData.putExtra("TEL_NO", veri[2]);
sendData.putExtra("EMAIL", veri[3]);
startActivity(sendData);
}
});
}
}
VERİTABANI
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
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 db, int oldVersion, int newVersion) {
}
}
     
 
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.