Android Studio - Complete Android Apps Tutorial – SQLite Database - Day 17 - 9.05 смотреть онлайн
SQLite Database Open source, lightweight relational database. Stored in /data/data/package_name/databases Private by default, only accessible by the application that created them. To share a database across applications, use Content Providers.
3
SQLite Database SQLiteOpenHelper wraps up the creating, opening and upgrading of databases. Extends SQLiteOpenHelper and override the Constructor onCreate onUpgrade
4
SQLite Database With an instance of own subclass of SQLiteOpenHelper, call getReadableDatabase or getWritableDatabase to return a read-only or a writable SQLite database Two approaches of using SQLite database to avoid IllegalStateException Open it once and never close it Right before we need to read or write to the database, open it and close it immediately after the operation is done – not possible if using SimpleCursorAdapter
5
public MyDatabaseHelperContext context supercontext, "todo.db", null, 1;
SQLiteOpenHelper constructor 1st parameter, the context, is usually the only parameter for the constructor for our subclass 2nd parameter is the name of the sqlite file 3rd parameter is an instance of CursorFactory, used for creating cursor objects, which usually is set to null 4th parameter is the version of the sqlite database, started from 1
6
@Override public void onCreateSQLiteDatabase db db.execSQL"create table tasks _id " + "integer primary key autoincrement," + "title text, details text;";
SQLiteOpenHelper onCreate Will be called only when the sqlite file e.g. todo.db has not been created Call execSQL and supply the SQL statements to create one or more database tables The field “_id” is required if we are using CursorAdapter to populate a ListView with Cursor
7
@Override public void onUpgradeSQLiteDatabase db, int oldVersion, int newVersion db.execSQL"drop table tasks"; onCreatedb;
SQLiteOpenHelper onUpgrade Will be called only when the sqlite file version number in the constructor is higher than the version number associated to the existing sqlite file created previously with an older version of the app Simplest implementation of a schema change is to drop the existing table and create a new one
8
Writing data to SQLite Database ContentValues are used to insert new rows into database tables or update existing rows. Each ContentValues object represents a single row. The constructor of ContentValues takes an integer to set it's initial size
9
Using ContentValues To add ContentValues values = new ContentValues2; values.put“title”, “Meeting”; values.put“details”, “Financial report”; db.insert“tasks”, null, values; To edit db.update“tasks”, values, “_id=?”, new String[]id; To delete db.delete“tasks”, “_id=?”, new String[]id;
10
SQLite Transactions Call setTransactionSuccessful after all operation in the try block is success and only then endTransaction will commit the changes to the file To avoid scenario that only half of the operation are completed db.beginTransaction; try … db.setTransactionSuccessful; finally db.endTransaction;
11
Getting data from SQLite Database Queries are returned as Cursor objects, which are pointers to a subset of the data. Two ways to execute a query
Cursor cursor = db.rawQuery“select _id, title, ” + “details from tasks order by title”, null;
Cursor cursor = db.query“tasks”, new String[] “_id”, “title”, “details”, null, null, null, null, “title”;
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Android Studio - Complete Android Apps Tutorial – SQLite Database - Day 17 - 9.05» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.