Best code examples for Android SQLiteDatabase class (android.database.sqlite.SQLiteDatabase)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android SQLiteDatabase class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android SQLiteDatabase examples from Open Source projects
This code example shows how to use the following methods: execSQL
49:	db.execSQL("CREATE TABLE orgs (id INTEGER PRIMARY KEY);"); 
50:	db.execSQL("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, avatarurl TEXT);"); 
51:	db.execSQL("CREATE TABLE repos (id INTEGER PRIMARY KEY, repoId INTEGER, orgId INTEGER, name TEXT, ownerId INTEGER, private INTEGER, fork INTEGER, description TEXT, forks INTEGER, watchers INTEGER, language TEXT, hasIssues INTEGER, mirrorUrl TEXT);"); 
-
57:	db.execSQL("DROP TABLE IF EXISTS orgs"); 
58:	db.execSQL("DROP TABLE IF EXISTS users"); 
59:	db.execSQL("DROP TABLE IF EXISTS repos"); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: beginTransaction, endTransaction, setTransactionSuccessful
129:	db.beginTransaction(); 
-
131:	persistableResource.store(db, items); 
132:	db.setTransactionSuccessful(); 
-
134:	db.endTransaction(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: close
181:	syncDatabase.close(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: beginTransaction, endTransaction, setTransactionSuccessful, update
126:	db.beginTransaction(); 
-
129:	int count = db.update("tests", values, newSelection, selectionArgs); 
130:	db.setTransactionSuccessful(); 
-
134:	db.endTransaction(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: execSQL, setVersion
62:	db.execSQL(queryBuilder.toString()); 
63:	db.setVersion(DB_VERSION); 
-
72:	db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: execSQL, insert
69:	userDao.save(sqLiteDatabase, account.getUser()); 
-
76:	clearDeletedAccount(sqLiteDatabase, account); // 确保一个帐号在数据库中只有一条记录,一个状态 
-
78:	long rowId = sqLiteDatabase.insert(TABLE, null, values); 
-
94:	sqLiteDatabase.execSQL(sql.toString()); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: execSQL
133:	db.execSQL(FEED_SQL); 
134:	db.execSQL(SOCIAL_FEED_SQL); 
135:	db.execSQL(FOLDER_SQL); 
136:	db.execSQL(USER_SQL); 
137:	db.execSQL(STORY_SQL); 
138:	db.execSQL(COMMENT_SQL); 
139:	db.execSQL(REPLY_SQL); 
140:	db.execSQL(CLASSIFIER_SQL); 
141:	db.execSQL(FEED_FOLDER_SQL); 
142:	db.execSQL(SOCIALFEED_STORIES_SQL); 
143:	db.execSQL(OFFLINE_UPDATE_SQL); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: close, delete, insert, query
100:	db.delete(TABLE_PLAYLIST, "PlaylistName = ?", whereArgs); 
-
102:	db.close(); 
-
311:	Cursor query = db.query(TABLE_PLAYLIST, columns, "PlaylistName = ?", selectionArgs, null, null, null); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: execSQL
75:	db.execSQL(CREATE_BOOKMARKS_TABLE); 
76:	db.execSQL(CREATE_TAGS_TABLE); 
77:	db.execSQL(CREATE_BOOKMARK_TAG_TABLE); 
78:	db.execSQL(BOOKMARK_TAGS_INDEX); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: beginTransaction, delete, endTransaction, setTransactionSuccessful
281:	db.beginTransaction(); 
282:	db.delete(TABLE, COLUMN_USERID + "='" + userId + "'", null); 
283:	db.setTransactionSuccessful(); 
-
285:	db.endTransaction(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: execSQL
206:	db.execSQL(CREATE_ACCOUNT_TABLE_SQL); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: delete, execSQL, rawQuery
448:	database.delete("exectable", null, null); 
-
450:	Cursor cursor = database.rawQuery("select * from exectable", null); 
-
454:	database.execSQL("insert into exectable (first_column) values (?);", new String[]{}); 
455:	Cursor cursor2 = database.rawQuery("select * from exectable", new String[]{null}); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: close, beginTransaction, endTransaction, getVersion, setTransactionSuccessful
121:	int version = db.getVersion(); 
-
123:	db.beginTransaction(); 
-
126:	onCreate(db); 
-
128:	onUpgrade(db, version, mNewVersion); 
-
130:	db.setVersion(mNewVersion); 
131:	db.setTransactionSuccessful(); 
-
133:	db.endTransaction(); 
-
152:	db.close(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: close, beginTransaction, compileStatement, endTransaction, isOpen
31:	} 
-
34:	return (db != null && db.isOpen()); 
-
40:	db.close(); 
-
79:	db.beginTransaction(); 
-
87:	db.endTransaction(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: close
104:	this.mDatabase.close(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: put, insert
46:	ContentValues cv=new ContentValues(); 
-
48:	cv.put("name", name); 
49:	cv.put("address", address); 
50:	cv.put("type", type); 
51:	cv.put("notes", notes); 
-
53:	getWritableDatabase().insert("restaurants", "name", cv); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: beginTransaction, endTransaction, setTransactionSuccessful
49:	db.beginTransaction(); 
50:	createTables(db); 
51:	initTables(db); 
52:	db.setTransactionSuccessful(); 
53:	db.endTransaction(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: close, isOpen, isReadOnly
81:	if (mDatabase != null && mDatabase.isOpen() && !mDatabase.isReadOnly()) { 
-
129:	try { mDatabase.close(); } catch (Exception e) { } 
-
152:	if (mDatabase != null && mDatabase.isOpen()) { 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: beginTransaction, update
101:	db.beginTransaction(); 
-
103:	retval = db.update(table, values, selection, selectionArgs); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: execSQL
282:	sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + KEYVAL_TABLE_NAME + "(" + 
-
286:	sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + GOOGLE_MANAGED_ITEMS_TABLE_NAME + "(" + 
-
289:	sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + VIRTUAL_CURRENCY_TABLE_NAME + "(" + 
-
293:	sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + VIRTUAL_GOODS_TABLE_NAME + "(" + 
-
298:	sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + METADATA_TABLE_NAME + "(" + 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: insert
118:	mDb.insert(table, null, cv); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: close, isOpen, isReadOnly
112:	if (mDatabase != null && mDatabase.isOpen() && !mDatabase.isReadOnly()) { 
-
164:	try { mDatabase.close(); } catch (Exception e) { } 
-
191:	if (mDatabase != null && mDatabase.isOpen()) { 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: execSQL, rawQuery
80:	Cursor res = database.rawQuery("select name from sqlite_master where type = 'table' and name = 'dict_tbl'", null); 
-
86:	database.execSQL("insert into cards (ordinal, question, answer, note)" + 
-
92:	Cursor result = database.rawQuery("SELECT _id FROM dict_tbl", null); 
-
95:	result = database.rawQuery("SELECT _id FROM learn_tbl", null); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: execSQL
39:	db.execSQL(q.getExecutableSql()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: execSQL
83:	db.execSQL(sql); 
-
98:	db.execSQL(sql); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: execSQL, insert
84:	db.execSQL( 
-
95:	db.execSQL("CREATE INDEX lookup_identity ON identity(" + 
-
98:	db.execSQL( 
-
106:	db.execSQL("CREATE INDEX lookup_feature ON feature(" + 
-
114:	db.insert("identity", "_id", values); 
-
120:	db.insert("feature", "_id", values); 
-
122:	db.insert("feature", "_id", values); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: execSQL, setVersion
101:	db.execSQL(PROFILES_TABLE_UPGRADE_6_7_1); 
102:	db.execSQL(PROFILES_TABLE_UPGRADE_6_7_2); 
103:	db.execSQL(PROFILES_TABLE_UPGRADE_6_7_3); 
104:	db.execSQL(PROFILES_TABLE_UPGRADE_6_7_4); 
-
114:	db.execSQL(PROFILES_TABLE_UPGRADE_3_4); 
115:	db.execSQL(PROFILES_TABLE_UPGRADE_4_5); 
116:	db.execSQL(PROFILES_TABLE_UPGRADE_5_6); 
-
118:	db.setVersion(DATABASE_VERSION); 
-
120:	db.execSQL(PROFILES_TABLE_UPGRADE_3_4); 
121:	db.execSQL(PROFILES_TABLE_UPGRADE_4_5); 
122:	db.execSQL(PROFILES_TABLE_UPGRADE_5_6); 
-
124:	db.setVersion(DATABASE_VERSION); 
-
126:	db.execSQL(PROFILES_TABLE_UPGRADE_4_5); 
127:	db.execSQL(PROFILES_TABLE_UPGRADE_5_6); 
-
129:	db.setVersion(DATABASE_VERSION); 
-
131:	db.execSQL(PROFILES_TABLE_UPGRADE_5_6); 
-
133:	db.setVersion(DATABASE_VERSION); 
-
136:	db.setVersion(DATABASE_VERSION); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: execSQL
202:	db.execSQL("DROP TABLE IF EXISTS "+TABLE_TM_NAME); 
203:	db.execSQL("DROP TABLE IF EXISTS "+GOODS_CATEGORY_TM_NAME); 
204:	db.execSQL("DROP TABLE IF EXISTS "+GOODS_TM_NAME); 
205:	db.execSQL("DROP TABLE IF EXISTS "+ELE_CART_TM_NAME); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: execSQL
183:	db.execSQL(CREATE_TABLE); 
184:	db.execSQL(CREATE_INDEX); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: close
359:	database.close(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: execSQL, insert
84:	db.execSQL( 
-
95:	db.execSQL("CREATE INDEX lookup_identity ON identity(" + 
-
98:	db.execSQL( 
-
106:	db.execSQL("CREATE INDEX lookup_feature ON feature(" + 
-
114:	db.insert("identity", "_id", values); 
-
120:	db.insert("feature", "_id", values); 
-
122:	db.insert("feature", "_id", values); 
-
137:	db.execSQL("DROP TABLE feature"); 
138:	db.execSQL("DROP TABLE identity"); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: execSQL, insert, query
95:	Cursor c = 
-
136:	db.execSQL(DBVERSION_CREATE); 
-
139:	db.insert(TABLE_DBVERSION, null, args); 
-
141:	db.execSQL(TABLE_CREATE); 
-
158:	db.insert(TABLE_DBVERSION, null, args); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: close
38:	db.close(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: execSQL, setVersion
62:	db.execSQL(queryBuilder.toString()); 
63:	db.setVersion(DB_VERSION); 
-
72:	db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: execSQL
44:	sqLiteDatabase.execSQL( 
-
56:	sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: close, execSQL, rawQuery
23:	droidsniffDB.execSQL(CREATE_PREFERENCES); 
24:	droidsniffDB.execSQL(CREATE_BLACKLIST); 
-
120:	Cursor cur = droidsniffDB.rawQuery("SELECT count(id) as count FROM DROIDSNIFF_PREFERENCES where name = 'update';", new String[] {}); 
-
124:	droidsniffDB.execSQL("INSERT INTO DROIDSNIFF_PREFERENCES (name, value) values ('update', ?);", 
-
127:	droidsniffDB.execSQL("UPDATE DROIDSNIFF_PREFERENCES SET value=? WHERE name='update';", 
-
130:	droidsniffDB.close(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: execSQL
30:	db.execSQL("CREATE TABLE pending_incoming_messages (" 
-
41:	db.execSQL("CREATE TABLE pending_outgoing_messages (" 
-
54:	db.execSQL("DROP TABLE IF EXISTS pending_incoming_messages"); 
55:	db.execSQL("DROP TABLE IF EXISTS pending_outgoing_messages"); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: execSQL
29:	db.execSQL("CREATE TABLE NFAVORITES (_ID INTEGER PRIMARY KEY AUTOINCREMENT,VIDEOID VARCHAR(40), TITLE VARCHAR(100),TPYE INTEGER,CHANNELID TEXT)"); 
30:	db.execSQL("CREATE TABLE NHISTORY (_ID INTEGER PRIMARY KEY AUTOINCREMENT,VIDEOID VARCHAR(40), TITLE VARCHAR(100),TIME VARCHAR(20),TPYE INTEGER,CHANNELID TEXT)"); 
-
33:	db.execSQL("CREATE TABLE DOWNLOADLIST (_ID INTEGER PRIMARY KEY AUTOINCREMENT,AID VARCHAR(40), VID VARCHAR(40),LOCALURI VARCHAR, REMOTEURI VARCHAR,TITLE VARCHAR(255), DURATION INTEGER,I INTEGER, MD5 VARCHAR,STATE INTEGER,DOWNLOADID INTEGER)"); 
-
36:	db.execSQL("ALTER TABLE DOWNLOADLIST ADD SIZE INTEGER"); 
-
39:	db.execSQL("ALTER TABLE DOWNLOADLIST ADD VTYPE VARCHER(10)"); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: execSQL
46:	db.execSQL("CREATE TABLE "+ HASHTAG_TABLE +" (" + 
-
51:	db.execSQL("CREATE TABLE "+ TWEET_TABLE +" (" + 
-
59:	db.execSQL("CREATE TABLE "+ TWEET_USER_TABLE +" (" + 
-
68:	db.execSQL("CREATE TABLE "+ ID_INFORMATION_TABLE +" (" + 
Full Snippet Info
7
CodeRank
Related Android SQLiteDatabase Questions & Answers:
Other Android SQLiteDatabase Examples
1:		public void closeDB() {
2:			SQLiteDatabase db = this.getReadableDatabase();
3:			if (db != null && db.isOpen())
4:				db.close();

Read More

2:		 */
3:		public void deleteToDo(long tado_id) {
4:			SQLiteDatabase db = this.getWritableDatabase();
5:			db.delete(TABLE_TODO, KEY_ID + " = ?",
6:					new String[] { String.valueOf(tado_id) });

Read More

1:		public void deleteContact(Contact contact) {
2:			SQLiteDatabase db = this.getWritableDatabase();
3:			db.delete(TABLE_CONTACTS, KEY_ID + " = ?",
4:					new String[] { String.valueOf(contact.getID()) });

Read More

See Code Examples for Android SQLiteDatabase Methods: