SQLiteDatabase insert - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for SQLiteDatabase insert method.

This code example shows how to use the following methods: execSQL, insert
		values.put("Search_Proxy_Url", account.getSearchProxyUrl());
		values.put("Token_Expired_At",
				account.getTokenExpiredAt() == null? -1L : account.getTokenExpiredAt().getTime());
 
		if (account.getUser() != null) {
			userDao.save(sqLiteDatabase, account.getUser());
		} 
		 
		if (account.isDefault()) {
			resetDefaultAccount(sqLiteDatabase);  // 清除原有的默认帐号状态设置
		} 
		 
		clearDeletedAccount(sqLiteDatabase, account); // 确保一个帐号在数据库中只有一条记录,一个状态
 
		long rowId = sqLiteDatabase.insert(TABLE, null, values);
		//You can access the ROWID of an SQLite table using one the special 
		//column names ROWID, _ROWID_, or OID. 
		//If a table contains a column of type INTEGER PRIMARY KEY, 
		//then that column becomes an alias for the ROWID. 
		//You can then access the ROWID using any of four different names, 

8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: close, delete, insert, query
		if(fileName != null)
			mActivity.deleteFile(fileName);
		//mActivity.openFileOutput(fileName, Context.MODE_PRIVATE).getFD(). 
 
		String[] whereArgs = {playlistName};
		db.delete(TABLE_PLAYLIST, "PlaylistName = ?", whereArgs);
 
		db.close();
	} 
 
	@Override 
	public ArrayList<String> getAvailablePlaylists() {
		ArrayList<String> playlists = new ArrayList<String>(); 
		SQLiteDatabase db = mActivity.openOrCreateDatabase(DB_NAME, Context.MODE_PRIVATE, null);
 
		String[] columns = {"PlaylistName"};
		Cursor query = db.query(TABLE_PLAYLIST, columns, null, null, null, null, "PlaylistName ASC");
 
		if(query != null){
			query.moveToFirst();

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: execSQL, insert
     * Called when a new database is created. 
     * @param db The database to initialize. 
     */ 
    @Override 
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(
            "CREATE TABLE identity(" + 
                "_id INTEGER," + 
                "category TEXT NOT NULL," + 
                "type TEXT NOT NULL," + 
                "lang TEXT NOT NULL DEFAULT ''," + 
                "name TEXT NOT NULL DEFAULT ''," + 
                "jid TEXT," + 
                "PRIMARY KEY(_id)" + 
            ")" 
        ); 
        db.execSQL("CREATE INDEX lookup_identity ON identity(" +
                   "category ASC, type ASC, lang ASC, name ASC, _id ASC" + 
                   ")"); 
        db.execSQL(

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: execSQL, insert, query
			m_db = myCtx.openOrCreateDatabase(DATABASE_NAME, 0,null);
 
			// Check for the existence of the DBVERSION table 
			// If it doesn't exist than create the overall data, 
			// otherwise double check the version 
			Cursor c =
				m_db.query("sqlite_master", new String[] { "name" },
						"type='table' and name='"+TABLE_DBVERSION+"'", null, null, null, null);
			int numRows = c.getCount();
			if (numRows < 1)
			{ 
				CreateDatabase(m_db);
			} 
			else 
			{ 
				int version=0;
				Cursor vc = m_db.query(true, TABLE_DBVERSION, new String[] {"version"},
						null, null, null, null, null,null); 
				if(vc.getCount() > 0) {
				    vc.moveToLast();

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: execSQL, insert
     * Called when a new database is created. 
     * @param db The database to initialize. 
     */ 
    @Override 
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(
            "CREATE TABLE identity(" + 
                "_id INTEGER," + 
                "category TEXT NOT NULL," + 
                "type TEXT NOT NULL," + 
                "lang TEXT NOT NULL DEFAULT ''," + 
                "name TEXT NOT NULL DEFAULT ''," + 
                "jid TEXT," + 
                "PRIMARY KEY(_id)" + 
            ")" 
        ); 
        db.execSQL("CREATE INDEX lookup_identity ON identity(" +
                   "category ASC, type ASC, lang ASC, name ASC, _id ASC" + 
                   ")"); 
        db.execSQL(

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related SQLiteDatabase insert Questions & Answers:

Other SQLiteDatabase insert Examples

68:			if (!isSiteExists(db, site.getRSSLink())) {
69:				// site not existed, create a new row
70:				db.insert(TABLE_RSS, null, values);
71:				db.close();
72:			} else {

Read More

62:	
63:			// Inserting Row
64:			db.insert(TABLE_CONTACTS, null, values);
65:			db.close(); // Closing database connection
66:		}

Read More

7:	
8:			// Inserting Row
9:			db.insert(TABLE_CONTACTS, null, values);
10:			db.close(); // Closing database connection
11:		}

Read More

insert Method Overview
Convenience method for inserting a row into the database.
See Code Examples for other Android SQLiteDatabase Methods: