Java Code Examples for android.database.sqlite.SQLiteStatement.bindString()

The following are Jave code examples for showing how to use bindString() of the android.database.sqlite.SQLiteStatement class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: healthvault-java-sdk   File: ViewProvider.java   Source Code and License Vote up 6 votes
public Uri insert(Uri uri, ContentValues values) {
	SQLiteDatabase sqlDb = dbHelper.getWritableDatabase();
	
	List<String> segments = uri.getPathSegments();
	String recordId = segments.get(1);
	String name = segments.get(3);

       String insertView = "Insert or replace into views (record_id, name, query, date_synced) values(?,?,?,?)";

       SQLiteStatement insertViewStmt = sqlDb.compileStatement(insertView);

       insertViewStmt.bindString(1, recordId);
       insertViewStmt.bindString(2, name);
       insertViewStmt.bindString(3, values.getAsString("query"));
       insertViewStmt.bindString(4, values.getAsString("date_synced"));
       insertViewStmt.execute();
       
       getContext()
               .getContentResolver()
               .notifyChange(uri, null);
      
       return uri;
}
 
Example 2
Project: sqlbrite-sqlcipher   File: BriteDatabaseTest.java   Source Code and License Vote up 6 votes
@Test public void executeInsertWithArgsThrowsAndDoesNotTrigger() {
  SQLiteStatement statement = real.compileStatement("INSERT INTO " + TABLE_EMPLOYEE + " ("
      + NAME + ", " + USERNAME + ") VALUES (?, ?)");
  statement.bindString(1, "Alice Aliison");
  statement.bindString(2, "alice");

  db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES)
      .skip(1) // Skip initial
      .subscribe(o);

  try {
    db.executeInsert(TABLE_EMPLOYEE, statement);
    fail();
  } catch (SQLException ignored) {
  }
  o.assertNoMoreEvents();
}
 
Example 3
Project: sctalk   File: SessionDao.java   Source Code and License Vote up 6 votes
/** @inheritdoc */
@Override
protected void bindValues(SQLiteStatement stmt, SessionEntity entity) {
    stmt.clearBindings();
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(1, id);
    }
    stmt.bindString(2, entity.getSessionKey());
    stmt.bindLong(3, entity.getPeerId());
    stmt.bindLong(4, entity.getPeerType());
    stmt.bindLong(5, entity.getLatestMsgType());
    stmt.bindLong(6, entity.getLatestMsgId());
    stmt.bindString(7, entity.getLatestMsgData());
    stmt.bindLong(8, entity.getTalkId());
    stmt.bindLong(9, entity.getCreated());
    stmt.bindLong(10, entity.getUpdated());
}
 
Example 4
Project: OpenHub   File: LocalUserDao.java   Source Code and License Vote up 6 votes
@Override
protected final void bindValues(SQLiteStatement stmt, LocalUser entity) {
    stmt.clearBindings();
    stmt.bindString(1, entity.getLogin());
 
    String name = entity.getName();
    if (name != null) {
        stmt.bindString(2, name);
    }
 
    String avatarUrl = entity.getAvatarUrl();
    if (avatarUrl != null) {
        stmt.bindString(3, avatarUrl);
    }
 
    Integer followers = entity.getFollowers();
    if (followers != null) {
        stmt.bindLong(4, followers);
    }
 
    Integer following = entity.getFollowing();
    if (following != null) {
        stmt.bindLong(5, following);
    }
}
 
Example 5
Project: LookWeather   File: CityDao.java   Source Code and License Vote up 6 votes
@Override
protected final void bindValues(SQLiteStatement stmt, City entity) {
    stmt.clearBindings();
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(1, id);
    }
 
    String cityName = entity.getCityName();
    if (cityName != null) {
        stmt.bindString(2, cityName);
    }
    stmt.bindLong(3, entity.getCityCode());
    stmt.bindLong(4, entity.getProvinceId());
}
 
Example 6
Project: wallpaperboard   File: Database.java   Source Code and License Vote up 6 votes
public void deleteWallpapers(@NonNull List<Wallpaper> wallpapers) {
    if (!openDatabase()) {
        LogUtil.e("Database error: deleteWallpapers() failed to open database");
        return;
    }

    String query = "DELETE FROM " +TABLE_WALLPAPERS+ " WHERE " +KEY_URL+ " = ?";
    SQLiteStatement statement = mDatabase.get().mSQLiteDatabase.compileStatement(query);
    mDatabase.get().mSQLiteDatabase.beginTransaction();

    for (Wallpaper wallpaper : wallpapers) {
        statement.clearBindings();
        statement.bindString(1, wallpaper.getUrl());
        statement.execute();
    }

    mDatabase.get().mSQLiteDatabase.setTransactionSuccessful();
    mDatabase.get().mSQLiteDatabase.endTransaction();
}
 
Example 7
Project: Expert-Android-Programming   File: PhotoItemDao.java   Source Code and License Vote up 6 votes
/** @inheritdoc */
@Override
protected void bindValues(SQLiteStatement stmt, PhotoItem entity) {
	 stmt.clearBindings();
	 
     int c = 0;         
     Long id = entity.getId();
     ++c;
     if (id != null) {
     	 stmt.bindLong(c, id);
     }
    ++c; stmt.bindString(c, handleNull(entity.get_id()));
    ++c; stmt.bindString(c, handleNull(entity.getName()));
    ++c; stmt.bindString(c, handleNull(entity.getPath()));
    ++c; stmt.bindString(c, handleNull(entity.getTag()));
    ++c; stmt.bindLong(c, entity.isStatus()?1:0);
}
 
Example 8
Project: CommonFramework   File: SceneDao.java   Source Code and License Vote up 6 votes
@Override
protected final void bindValues(SQLiteStatement stmt, Scene entity) {
    stmt.clearBindings();
    stmt.bindLong(1, entity.getId());
 
    String name = entity.getName();
    if (name != null) {
        stmt.bindString(2, name);
    }
 
    String iconUrl = entity.getIconUrl();
    if (iconUrl != null) {
        stmt.bindString(3, iconUrl);
    }
 
    String type = entity.getType();
    if (type != null) {
        stmt.bindString(4, type);
    }
    stmt.bindLong(5, entity.getVisiablity() ? 1L: 0L);
}
 
Example 9
Project: LookWeather   File: ProvinceDao.java   Source Code and License Vote up 5 votes
@Override
protected final void bindValues(SQLiteStatement stmt, Province entity) {
    stmt.clearBindings();
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(1, id);
    }
 
    String provinceName = entity.getProvinceName();
    if (provinceName != null) {
        stmt.bindString(2, provinceName);
    }
    stmt.bindLong(3, entity.getProvinceCode());
}
 
Example 10
Project: CommonFramework   File: BannerDao.java   Source Code and License Vote up 5 votes
@Override
protected final void bindValues(SQLiteStatement stmt, Banner entity) {
    stmt.clearBindings();
    stmt.bindLong(1, entity.getId());
 
    String url = entity.getUrl();
    if (url != null) {
        stmt.bindString(2, url);
    }
 
    String type = entity.getType();
    if (type != null) {
        stmt.bindString(3, type);
    }
}
 
Example 11
Project: Android-Code-Demos   File: UserDao.java   Source Code and License Vote up 5 votes
@Override
protected final void bindValues(SQLiteStatement stmt, User entity) {
    stmt.clearBindings();
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(1, id);
    }
 
    String name = entity.getName();
    if (name != null) {
        stmt.bindString(2, name);
    }
    stmt.bindLong(3, entity.getAge());
}
 
Example 12
Project: ShaddockVideoPlayer   File: VideoInfoDao.java   Source Code and License Vote up 5 votes
@Override
protected final void bindValues(SQLiteStatement stmt, VideoInfo entity) {
    stmt.clearBindings();
 
    Long ID = entity.getID();
    if (ID != null) {
        stmt.bindLong(1, ID);
    }
 
    Long fileID = entity.getFileID();
    if (fileID != null) {
        stmt.bindLong(2, fileID);
    }
 
    String name = entity.getName();
    if (name != null) {
        stmt.bindString(3, name);
    }
 
    String path = entity.getPath();
    if (path != null) {
        stmt.bindString(4, path);
    }
 
    String time = entity.getTime();
    if (time != null) {
        stmt.bindString(5, time);
    }
 
    String size = entity.getSize();
    if (size != null) {
        stmt.bindString(6, size);
    }
}
 
Example 13
Project: Bee-Analyzer   File: MapsActivity.java   Source Code and License Vote up 5 votes
public void InsertToSqlite(String imei, String latitude, String longitude, String out)
{
    SQLiteStatement statement = localdb.compileStatement("INSERT INTO position VALUES(?,?,?,datetime(),?)");
    statement.bindString(1, imei);
    statement.bindString(2, latitude);
    statement.bindString(3, longitude);
    statement.bindString(4, out);
    statement.executeInsert();
    statement.close();
}
 
Example 14
Project: Geoclick   File: DBHelper.java   Source Code and License Vote up 5 votes
public void Picture_Insert(String country, String city, String latitude, String longitude,
                           byte[] thumbnail, String mainImg) {

    // open read and write database
    SQLiteDatabase db = getWritableDatabase();
    // execute insert query

    SQLiteStatement p = db.compileStatement("INSERT INTO Picture values(?,?,?,?,?,?,?);");
    p.bindNull(1);
    p.bindString(2, country);
    p.bindString(3, city);
    p.bindString(4, latitude);
    p.bindString(5, longitude);
    p.bindBlob(6, thumbnail);
    p.bindString(7, mainImg);
    p.execute();
    db.close();
    Log.d("Database :", "INSERT Complete!");
}
 
Example 15
Project: GitHub   File: SimpleEntityNotNullDao.java   Source Code and License Vote up 5 votes
@Override
protected final void bindValues(SQLiteStatement stmt, SimpleEntityNotNull entity) {
    stmt.clearBindings();
    stmt.bindLong(1, entity.getId());
    stmt.bindLong(2, entity.getSimpleBoolean() ? 1L: 0L);
    stmt.bindLong(3, entity.getSimpleByte());
    stmt.bindLong(4, entity.getSimpleShort());
    stmt.bindLong(5, entity.getSimpleInt());
    stmt.bindLong(6, entity.getSimpleLong());
    stmt.bindDouble(7, entity.getSimpleFloat());
    stmt.bindDouble(8, entity.getSimpleDouble());
    stmt.bindString(9, entity.getSimpleString());
    stmt.bindBlob(10, entity.getSimpleByteArray());
}
 
Example 16
Project: popomusic   File: VideoBeanDao.java   Source Code and License Vote up 4 votes
@Override
protected final void bindValues(SQLiteStatement stmt, VideoBean entity) {
    stmt.clearBindings();
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(1, id);
    }
 
    String dataType = entity.getDataType();
    if (dataType != null) {
        stmt.bindString(2, dataType);
    }
 
    String title = entity.getTitle();
    if (title != null) {
        stmt.bindString(3, title);
    }
 
    String text = entity.getText();
    if (text != null) {
        stmt.bindString(4, text);
    }
 
    String description = entity.getDescription();
    if (description != null) {
        stmt.bindString(5, description);
    }
 
    String image = entity.getImage();
    if (image != null) {
        stmt.bindString(6, image);
    }
 
    String actionUrl = entity.getActionUrl();
    if (actionUrl != null) {
        stmt.bindString(7, actionUrl);
    }
    stmt.bindLong(8, entity.getShade() ? 1L: 0L);
 
    String playUrl = entity.getPlayUrl();
    if (playUrl != null) {
        stmt.bindString(9, playUrl);
    }
 
    String category = entity.getCategory();
    if (category != null) {
        stmt.bindString(10, category);
    }
    stmt.bindLong(11, entity.getDuration());
 
    String icon = entity.getIcon();
    if (icon != null) {
        stmt.bindString(12, icon);
    }
}
 
Example 17
Project: AndroidBackendlessChat   File: BThreadDao.java   Source Code and License Vote up 4 votes
/** @inheritdoc */
@Override
protected void bindValues(SQLiteStatement stmt, BThread entity) {
    stmt.clearBindings();
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(1, id);
    }
 
    String entityID = entity.getEntityID();
    if (entityID != null) {
        stmt.bindString(2, entityID);
    }
 
    java.util.Date creationDate = entity.getCreationDate();
    if (creationDate != null) {
        stmt.bindLong(3, creationDate.getTime());
    }
 
    Boolean hasUnreadMessages = entity.getHasUnreadMessages();
    if (hasUnreadMessages != null) {
        stmt.bindLong(4, hasUnreadMessages ? 1l: 0l);
    }
 
    Boolean deleted = entity.getDeleted();
    if (deleted != null) {
        stmt.bindLong(5, deleted ? 1l: 0l);
    }
 
    String name = entity.getName();
    if (name != null) {
        stmt.bindString(6, name);
    }
 
    java.util.Date LastMessageAdded = entity.getLastMessageAdded();
    if (LastMessageAdded != null) {
        stmt.bindLong(7, LastMessageAdded.getTime());
    }
 
    Integer type = entity.getType();
    if (type != null) {
        stmt.bindLong(8, type);
    }
 
    String creatorEntityId = entity.getCreatorEntityId();
    if (creatorEntityId != null) {
        stmt.bindString(9, creatorEntityId);
    }
 
    String imageUrl = entity.getImageUrl();
    if (imageUrl != null) {
        stmt.bindString(10, imageUrl);
    }
 
    String rootKey = entity.getRootKey();
    if (rootKey != null) {
        stmt.bindString(11, rootKey);
    }
 
    String apiKey = entity.getApiKey();
    if (apiKey != null) {
        stmt.bindString(12, apiKey);
    }
 
    Long creator_ID = entity.getCreator_ID();
    if (creator_ID != null) {
        stmt.bindLong(13, creator_ID);
    }
}
 
Example 18
Project: rongyunDemo   File: GroupsDao.java   Source Code and License Vote up 4 votes
/** @inheritdoc */
@Override
protected void bindValues(SQLiteStatement stmt, Groups entity) {
    stmt.clearBindings();
    stmt.bindString(1, entity.getGroupsId());

    String name = entity.getName();
    if (name != null) {
        stmt.bindString(2, name);
    }

    String portraitUri = entity.getPortraitUri();
    if (portraitUri != null) {
        stmt.bindString(3, portraitUri);
    }

    String displayName = entity.getDisplayName();
    if (displayName != null) {
        stmt.bindString(4, displayName);
    }

    String role = entity.getRole();
    if (role != null) {
        stmt.bindString(5, role);
    }

    String bulletin = entity.getBulletin();
    if (bulletin != null) {
        stmt.bindString(6, bulletin);
    }

    String timestamp = entity.getTimestamp();
    if (timestamp != null) {
        stmt.bindString(7, timestamp);
    }

    String nameSpelling = entity.getNameSpelling();
    if (nameSpelling != null) {
        stmt.bindString(8, nameSpelling);
    }
}
 
Example 19
Project: sealtalk-android-master   File: GroupMemberDao.java   Source Code and License Vote up 4 votes
/** @inheritdoc */
@Override
protected void bindValues(SQLiteStatement stmt, GroupMember entity) {
    stmt.clearBindings();
    stmt.bindString(1, entity.getGroupId());
    stmt.bindString(2, entity.getUserId());

    String name = entity.getName();
    if (name != null) {
        stmt.bindString(3, name);
    }

    String portraitUri = entity.getPortraitUri().toString();
    if (portraitUri != null) {
        stmt.bindString(4, portraitUri);
    }

    String displayName = entity.getDisplayName();
    if (displayName != null) {
        stmt.bindString(5, displayName);
    }

    String nameSpelling = entity.getNameSpelling();
    if (nameSpelling != null) {
        stmt.bindString(6, nameSpelling);
    }

    String displayNameSpelling = entity.getDisplayNameSpelling();
    if (displayNameSpelling != null) {
        stmt.bindString(7, displayNameSpelling);
    }

    String groupName = entity.getGroupName();
    if (groupName != null) {
        stmt.bindString(8, groupName);
    }

    String groupNameSpelling = entity.getGroupNameSpelling();
    if (groupNameSpelling != null) {
        stmt.bindString(9, groupNameSpelling);
    }

    String groupPortraitUri = entity.getGroupPortraitUri();
    if (groupPortraitUri != null) {
        stmt.bindString(10, groupPortraitUri);
    }
}
 
Example 20
Project: GitHub   File: SimpleEntityDao.java   Source Code and License Vote up 4 votes
@Override
protected final void bindValues(SQLiteStatement stmt, SimpleEntity entity) {
    stmt.clearBindings();
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(1, id);
    }
 
    Boolean simpleBoolean = entity.getSimpleBoolean();
    if (simpleBoolean != null) {
        stmt.bindLong(2, simpleBoolean ? 1L: 0L);
    }
 
    Byte simpleByte = entity.getSimpleByte();
    if (simpleByte != null) {
        stmt.bindLong(3, simpleByte);
    }
 
    Short simpleShort = entity.getSimpleShort();
    if (simpleShort != null) {
        stmt.bindLong(4, simpleShort);
    }
 
    Integer simpleInt = entity.getSimpleInt();
    if (simpleInt != null) {
        stmt.bindLong(5, simpleInt);
    }
 
    Long simpleLong = entity.getSimpleLong();
    if (simpleLong != null) {
        stmt.bindLong(6, simpleLong);
    }
 
    Float simpleFloat = entity.getSimpleFloat();
    if (simpleFloat != null) {
        stmt.bindDouble(7, simpleFloat);
    }
 
    Double simpleDouble = entity.getSimpleDouble();
    if (simpleDouble != null) {
        stmt.bindDouble(8, simpleDouble);
    }
 
    String simpleString = entity.getSimpleString();
    if (simpleString != null) {
        stmt.bindString(9, simpleString);
    }
 
    byte[] simpleByteArray = entity.getSimpleByteArray();
    if (simpleByteArray != null) {
        stmt.bindBlob(10, simpleByteArray);
    }
}