Langsung ke konten utama

Postingan

Menampilkan postingan dengan label sqlite

Room Android Architecture

In Google I/O 2017, Google announced about Room Architecture for Android. This Architecture is used to maintain the State of Android Application when the orientation changes. As well as google announced about Room Architecture. Room We have more boiler plates while creating SQLite Database in Android even it is small. Room as a library used to remove the boiler plates like Cursors & Handlers and database can be handled with annotations and model classes. If we remember about Sugar ORM or Active Android , the same approach is dealt with Room.  We don't want to go for any third party libraries, when the official Android libraries give you an equal, or better solution. Life Cycle Activity We have faced the problem mostly as that  to maintain the State of Android Application when the orientation changes. The Life Cycle Activity used to handle the state easily. Coding Part Create a new project in Android Studio. First, Add Google’s maven repository to your project-level build.g...

SQLiteToExcel - v1.0.0

SQLiteToExcel is a Light weight Library to Convert SQLite Database to Excel. I have Released Newer Version for this Library. If your Requirement is only to export your SQLite Database, then this library is very much suitable. Otherwise you requirement is to import or export excel to db or vice-versa, then you go for my newer release. Please visit here to see about SQLite2XL Version 1.0.1 How to Download add the following library in your app level gradle file compile 'com.ajts.androidmads.SQLite2Excel:library:1.0.0' How to Use 1.AndroidManifest.xml Add the following line in your Manifest file <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 2.Library Initialization  This line is used to save the exported file in default location. SqliteToExcel sqliteToExcel = new SqliteToExcel(this, "helloworld.db"); This line is used to save the exported file in used preferred location. SqliteToExcel sqliteToExcel = new SqliteToExcel(this, ...

How to use External SQLite DB in Android

In this Post, I will explain how to import and use External SQLite DB in Android. You can import and use SQLite database with the extensions like .db, .db3,sqlite and sqlite3. The External DB is created with some desktop applications like SQLite Browser , SQLite Converter and so on. After Generating the DB paste that into your App's assets folder. Code: DBHelper.class Create a class named as DBHelper extending with SQLiteHelper . Paste the following code in that class. public class DBHelper extends SQLiteOpenHelper { Context context; String DB_PATH; String divider = "/"; String DB_NAME; public DBImporterExporter(Context context, String DB_NAME) { super(context, DB_NAME, null, 1); this.context = context; this.DB_NAME = DB_NAME; DB_PATH = divider + "data" + divider + "data" + divider + context.getPackageName() + divider + "databases/"; } public boolean isDataBaseExists() { Fi...

CRUD Operation using Active Android

Hello friends, today we will see a simple CRUD Example in Android using Active Android Library .This is a perfect alternate for SQLite in Android. About Active Android ActiveAndroid is an active record style ORM ( object relational mapper ). What does that mean exactly? Well, ActiveAndroid allows you to save and retrieve SQLite database records without ever writing a single SQL statement. ActiveAndroid takes care of all the setup for Accessing the database in android. Project Setup In the project you just created go to the app level build.gradle file and add these lines. dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.4.0' //Add this line compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT' } repositories { jcenter() //Add these two lines mavenCentral() maven { url "https://oss.sonatype.org/content/repositorie...

How to perform CRUD Operations in Android SQLite with Blob

In this post, I will show you how to perform CRUD ( C reate, R ead, U pdate and D elete) operation with Images from Gallery in SQLite which is embedded in Android devices. Codes: AndroidManifest.xml Don't forget to add the following permission in your manifest file. DBHelper.java Open DBHelper.java and replace it with the following code. package com.example.blob.helper; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class DBHelper extends SQLiteOpenHelper { static DBHelper dbhelper; static final String DATABASE_NAME = "IMAGE_EX"; static final int DATABASE_VERSION = 1; public static final String IMAGE_TABLE="image_table"; public static final String IMAGE_="image"; public static final String IMAGE_NAME="image_name"; public static final String IMAGE_ID="id"; public static final String IMAGE_EX = "CREATE TABLE ...