NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package com.ders.mobil1

import android.content.ContentValues
import android.content.Context
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper
import android.widget.Toast


val database_name ="Veritabanim"
val table_name = "kitaplar"
val col_name = "kitapadi"
val col_tarih = "tarih"
val col_id = "id"



class DataBaseHelper (var context: Context):SQLiteOpenHelper(context,
database_name,null,1) {
override fun onCreate(db: SQLiteDatabase?) {
//veri tabanı oluştugunda bir kez calısır
var createTable = " CREATE TABLE "+ table_name+"("+
col_id+ " INTEGER PRIMARY KEY AUTOINCREMENT,"+
col_name +" VARCHAR(256), "+
col_tarih+" INTEGER)"
db?.execSQL(createTable)
}

override fun onUpgrade(db: SQLiteDatabase?, oldVersion: Int, newVersion: Int) {
TODO("Not yet implemented")
// veri tabanı yükseltmek için kullanılır
}
//veri kaydetmek için fonksiyon tanımlıyoruz
fun İnsertData (kitap: kitap){
val db = this.writableDatabase
val cv = ContentValues()
cv.put(col_name,kitap.kitap_adi)
cv.put(col_tarih,kitap.kitap_tarih)
var sonuc= db.insert(table_name,null,cv)
if (sonuc == (-1).toLong()){
Toast.makeText(context,"hatalı", Toast.LENGTH_LONG).show()
}
else {
Toast.makeText(context,"başarılı", Toast.LENGTH_LONG).show()
}
}
// verileri okumak için fonksiyon tanımlıyoruz
fun readData(): MutableList<kitap> {
var liste:MutableList<kitap> = ArrayList()
val db = this.readableDatabase
var sorgu = "Select * from "+table_name
var sonuc= db.rawQuery(sorgu,null)
if(sonuc.moveToFirst()){
do {
var kitap = kitap()
kitap.kitap_id = sonuc.getString(sonuc.getColumnIndex(col_id)).toInt()
kitap.kitap_adi = sonuc.getString(sonuc.getColumnIndex(col_name))
kitap.kitap_tarih = sonuc.getString(sonuc.getColumnIndex(col_tarih)).toInt()
liste.add(kitap)
}while (sonuc.moveToNext())
}
sonuc.close()
db.close()
return liste
}
//verilerimizi silmek için bu fonksiyonu tanımlıyoruz

fun deleteData(){
val db = this.writableDatabase
db.delete(table_name,null,null)
db.close()
}


}
     
 
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.