73 Android studio Sqlite | insert update delete in android studio with sqlite Part 3 HD

28.03.2019
Android sqlite database Insert Update Delete View Search part 3 Android Project Application : Android Login, Registration App, select insert update delete sqlite database What is SQLite? SQLite is an Open Source database. SQLite supports standard relational database features like SQL syntax, transactions and prepared statements. The database requires limited memory at runtime (approx. 250 KByte) which makes it a light weight database to embed into other runtimes. SQLite supports the data types TEXT (like String in Java), INTEGER (like long in Java) and REAL (like double in Java). All other types must be converted into one of these fields before getting saved in the database. SQLite is different from most other SQL database engines in that its primary design goal is to be simple: 1. Simple to administer 2. Simple to operate 3. Simple to embed in a larger program 4. Simple to maintain and customize Features of SQLite 1. Zero configuration – SQLite does not need to be installed as there is no setup procedure to use it. 2. Serverless – SQLite is not implemented as a separate server process. 3. Stable Cross-Platform Database File – The SQLite file format is cross-platform. A database file written on one machine can be copied to and used on a different machine with a different architecture. 4. Single Database File – A SQLite database is a single ordinary disk file that can be located anywhere in the directory hierarchy. 5. Compact – When optimized for size, the whole SQLite library with everything enable dis less than 400KB in size SQL Commands Create, Read, Update and Delete (CRUD) operations in SQLite DB SQLiteOpenHelper class (public abstract class) The android.database.sqlite.SQLiteOpenHelper class is used for database creation and version management. For performing any database operation, you have to provide the implementation of onCreate() and onUpgrade() methods of SQLiteOpenHelper class. SQLiteDatabase class It contains methods to be performed on sqlite database such as create, update, delete, select etc. Method of SQLiteDatabase class Java Snippet to creating a table (src/package/filename.java) public class DBClass extends SQLiteOpenHelper { static String DATABASE_NAME = "Sample"; static int DATABASE_VERSION = 1; public DBClass(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { String qry = "create table tableone(id integer,name text,avg real,total integer)"; db.execSQL(qry); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } } Java Snippet (src/package/MainActivity.java) @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); DBClass d= new DBClass(getApplicationContext()); } Java Snippet to inserting a row into table (src/package/filename.java) public void insertData() { SQLiteDatabase db = this.getWritableData

Похожие видео

Показать еще