NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

main activity


<?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>








-----------------------------------------------------------------------------------------------------------------------
package com.example.volka.rehber;

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;
//Veri tabani oluþturmak içn boþ bir java class açmamýz gerekmektedir. Java new class diyoruz
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); // id

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);
//hataya alt+enter make .... onclick seç
}

@Override
public void onClick(View v) {
//vt ye aktarýrken ilk buna aktar sonra vt ye koy
ContentValues contentValues = new ContentValues();
SQLiteDatabase sqLiteDatabase = vt.getWritableDatabase(); //vtmizi yazma iþlemi için açtýk
//okumalarda kullanýcak alanlar
String secim = null;
String secimAra[] = null;

switch (v.getId()) {
case R.id.addBtn:
//yeþil yerler tablodaki sütun adlarý ayný olmalý
contentValues.put("ISIM", name.getText().toString()); //tablodak sutun isimleri
contentValues.put("TEL_NO", phone.getText().toString());
contentValues.put("EMAIL", mail.getText().toString());
long rowID = sqLiteDatabase.insert("KAYIT", null, contentValues); //tablomuza verileri aktar
Toast.makeText(this, ":" + rowID + "nolu kayýt yapýldý", Toast.LENGTH_SHORT).show();
break;
case R.id.readBtn: //baska sayfada son kaydý gösterir
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()) { //verileri taramaya nerden baslamak isiyorsun ? move to first: en bastan basla
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);
// Toast.makeText(this, "" + numberStr + nameStr + phoneStr + mailStr, Toast.LENGTH_SHORT).show();
Intent sendData = new Intent(getApplicationContext(), ResultActivity.class); //verileri ekranda görebilmek içn
sendData.putExtra("ID", numberStr);
sendData.putExtra("ISIM", nameStr);
sendData.putExtra("TEL_NO", phoneStr);
sendData.putExtra("EMAIL", mailStr);
startActivity(sendData);
}
break;
//id si verileni sil
case R.id.deleteBtn:
snumberStr = number.getText().toString();// id sini göre sil
int silSiraNo = sqLiteDatabase.delete("KAYIT", "ID = " + numberStr, null);
if (silSiraNo == 0)
Toast.makeText(this, "silinecek kayýt dosyada yok.", Toast.LENGTH_SHORT).show();
else
Toast.makeText(this, snumberStr + "nolu kayýt silindi", Toast.LENGTH_SHORT).show();
//Toast.makeText(this, "Silinen ksyýt: "+silSiraNo, 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: //bütün verilerin ekranda görünceði sayfaya gönderiyor
Intent listIntent= new Intent(getApplicationContext(),ListelemeActivity.class);
startActivity(listIntent);
break;
//tüm kayýtlarý sil
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.updateBtn:
contentValues.put("ISIM", name.getText().toString());
contentValues.put("EMAIL", mail.getText().toString());
contentValues.put("TEL_NO", phone.getText().toString());
long ID = sqLiteDatabase.update("KAYIT",contentValues,"ID= "+number.getText().toString(),null);
Toast.makeText(this, ID+"nolu kayýt yapýldý", Toast.LENGTH_SHORT).show();
break;
case R.id.readShowBTn: //ilgili sayfata son kayýt gösterir
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;
}
}
}

     
 
what is notes.io
 

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

     
 
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.