本文整理匯總了Java中android.database.DatabaseUtils.sqlEscapeString方法的典型用法代碼示例。如果您正苦於以下問題:Java DatabaseUtils.sqlEscapeString方法的具體用法?Java DatabaseUtils.sqlEscapeString怎麽用?Java DatabaseUtils.sqlEscapeString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.database.DatabaseUtils
的用法示例。
在下文中一共展示了DatabaseUtils.sqlEscapeString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doesGoalExist
import android.database.DatabaseUtils; //導入方法依賴的package包/類
/**
* Used to check if a goal with matching title exists.
*
* @param goalTitle the desired title to search for
* @return true if a goal with matching title is found in table
*/
public boolean doesGoalExist(String goalTitle) {
// Sanitize goalTitle string before sql query
goalTitle = DatabaseUtils.sqlEscapeString(goalTitle);
// Query database for existence of a matching goal title
Cursor cursor = db.rawQuery(queryGoalTitle + goalTitle + "\"", null);
// return true if at least one instance of the goal title exists
if (cursor.getCount() > 0) {
// Close cursor
cursor.close();
// Return true because goal title exists
return true;
}
// Close the cursor
cursor.close();
// Return false because goal does not exist
return false;
}
示例2: getChatRoom
import android.database.DatabaseUtils; //導入方法依賴的package包/類
@Override
public QiscusChatRoom getChatRoom(String email, String distinctId) {
String query = "SELECT * FROM "
+ QiscusDb.RoomMemberTable.TABLE_NAME + " WHERE "
+ QiscusDb.RoomMemberTable.COLUMN_DISTINCT_ID + " = " + DatabaseUtils.sqlEscapeString(distinctId) + " "
+ "AND " + QiscusDb.RoomMemberTable.COLUMN_USER_EMAIL
+ " = " + DatabaseUtils.sqlEscapeString(email);
Cursor cursor = sqLiteDatabase.rawQuery(query, null);
while (cursor.moveToNext()) {
QiscusChatRoom qiscusChatRoom = getChatRoom(QiscusDb.RoomMemberTable.getRoomId(cursor));
if (qiscusChatRoom == null) {
cursor.close();
return null;
}
if (!qiscusChatRoom.isGroup()) {
cursor.close();
return qiscusChatRoom;
}
}
cursor.close();
return null;
}
示例3: updateRoomMember
import android.database.DatabaseUtils; //導入方法依賴的package包/類
@Override
public void updateRoomMember(int roomId, QiscusRoomMember qiscusRoomMember, String distinctId) {
distinctId = distinctId == null ? "default" : distinctId;
String where = QiscusDb.RoomMemberTable.COLUMN_ROOM_ID + " = " + roomId + " AND "
+ QiscusDb.RoomMemberTable.COLUMN_USER_EMAIL + " = " + DatabaseUtils.sqlEscapeString(qiscusRoomMember.getEmail());
sqLiteDatabase.beginTransaction();
try {
sqLiteDatabase.update(QiscusDb.RoomMemberTable.TABLE_NAME,
QiscusDb.RoomMemberTable.toContentValues(roomId, distinctId, qiscusRoomMember), where, null);
sqLiteDatabase.setTransactionSuccessful();
} catch (Exception e) {
e.printStackTrace();
} finally {
sqLiteDatabase.endTransaction();
}
addOrUpdate(qiscusRoomMember);
}
示例4: getMember
import android.database.DatabaseUtils; //導入方法依賴的package包/類
@Override
public QiscusRoomMember getMember(String email) {
String query = "SELECT * FROM "
+ QiscusDb.MemberTable.TABLE_NAME + " WHERE "
+ QiscusDb.MemberTable.COLUMN_USER_EMAIL + " = " + DatabaseUtils.sqlEscapeString(email);
Cursor cursor = sqLiteDatabase.rawQuery(query, null);
if (cursor.moveToNext()) {
QiscusRoomMember qiscusRoomMember = QiscusDb.MemberTable.getMember(cursor);
cursor.close();
return qiscusRoomMember;
} else {
cursor.close();
return null;
}
}
示例5: a
import android.database.DatabaseUtils; //導入方法依賴的package包/類
public final fu<Cursor> a(int paramInt, Bundle paramBundle)
{
kzp localkzp1 = new kzp(this.bn, this.c, a);
String str1 = this.d;
if (!TextUtils.isEmpty(str1))
{
String str2 = DatabaseUtils.sqlEscapeString(str1);
String str3 = str2.substring(1, -1 + str2.length());
SQLiteQueryBuilder localSQLiteQueryBuilder = localkzp1.r;
String str4 = String.valueOf(" AND (square_name LIKE '");
String str5 = String.valueOf("square_name");
String str6 = String.valueOf("square_name");
localSQLiteQueryBuilder.appendWhere(46 + String.valueOf(str4).length() + String.valueOf(str3).length() + String.valueOf(str5).length() + String.valueOf(str3).length() + String.valueOf(str6).length() + String.valueOf(str3).length() + str4 + str3 + "%' OR " + str5 + " LIKE '% " + str3 + "%' OR " + str6 + " GLOB '*[^a-zA-Z0-9'']" + str3 + "*')");
}
kzp localkzp2 = localkzp1.a(1);
if (this.Z) {
localkzp2.r.appendWhere(" AND restricted_domain!=''");
}
return localkzp2;
}
示例6: runQueryOnBackgroundThread
import android.database.DatabaseUtils; //導入方法依賴的package包/類
@Override
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
String where = null;
if (constraint != null) {
String filter = DatabaseUtils.sqlEscapeString(constraint.toString() + '%');
StringBuilder s = new StringBuilder();
s.append("(people.name LIKE ");
s.append(filter);
s.append(") OR (contact_methods.data LIKE ");
s.append(filter);
s.append(")");
where = s.toString();
}
return contentResolver.query(ContactMethods.CONTENT_EMAIL_URI, PROJECTION,
where, null, SORT_ORDER);
}
示例7: querySimple
import android.database.DatabaseUtils; //導入方法依賴的package包/類
private Cursor querySimple(SQLiteDatabase db, String stmt, Object... bindArgs) {
String[] args = null;
if (bindArgs != null) {
args = new String[bindArgs.length];
for (int i = 0; i < bindArgs.length; i++) {
Object arg = bindArgs[i];
if (arg instanceof String) {
args[i] = DatabaseUtils.sqlEscapeString((String) arg);
} else {
args[i] = arg.toString();
}
}
}
Cursor result = db.rawQuery(stmt, args);
Logger.i(stmt+";", args);
return result;
}
示例8: prepareWhere
import android.database.DatabaseUtils; //導入方法依賴的package包/類
/**
* Prepare the where command and adds the global settings
* @param where The where command
* @return The new where command
*/
private String prepareWhere(String where) {
// Ignore non-PlayMusic tracks
where = combineWhere(where, "LocalCopyType != 300");
// Loads only offline tracks
if (mOfflineOnly)
where = combineWhere(where, "LocalCopyPath IS NOT NULL");
// Search only items which contains the key
if (!TextUtils.isEmpty(mSearchKey)) {
String searchKey = DatabaseUtils.sqlEscapeString("%" + mSearchKey + "%");
String searchWhere = COLUMN_ALBUM + " LIKE " + searchKey;
searchWhere += " OR " + COLUMN_TITLE + " LIKE " + searchKey;
searchWhere += " OR " + COLUMN_ALBUM_ARTIST + " LIKE " + searchKey;
searchWhere += " OR " + COLUMN_ARTIST + " LIKE " + searchKey;
where = combineWhere(where, searchWhere);
}
return where;
}
示例9: prepareWhere
import android.database.DatabaseUtils; //導入方法依賴的package包/類
/**
* Prepare the where command and adds the global settings
* @param where The where command
* @return The new where command
*/
private String prepareWhere(String where) {
// Ignore non-PlayMusic tracks
where = combineWhere(where, "LocalCopyType != 300");
// Loads only offline tracks
if (mOfflineOnly)
where = combineWhere(where, "LocalCopyPath IS NOT NULL");
// Search only items which contains the key
if (!TextUtils.isEmpty(mSearchKey)) {
String searchKey = DatabaseUtils.sqlEscapeString("%" + mSearchKey + "%");
where = combineWhere(where, "(" + COLUMN_ARTIST + " LIKE " + searchKey + ")");
}
return where;
}
示例10: onCreate
import android.database.DatabaseUtils; //導入方法依賴的package包/類
@Override
public void onCreate(@NonNull SQLiteDatabase db) {
String CREATE_BOOKMARK_TABLE = "CREATE TABLE " +
DatabaseUtils.sqlEscapeString(TABLE_DOWNLOADS) + '(' +
DatabaseUtils.sqlEscapeString(KEY_ID) + " INTEGER PRIMARY KEY," +
DatabaseUtils.sqlEscapeString(KEY_URL) + " TEXT," +
DatabaseUtils.sqlEscapeString(KEY_TITLE) + " TEXT," +
DatabaseUtils.sqlEscapeString(KEY_SIZE) + " TEXT" + ')';
db.execSQL(CREATE_BOOKMARK_TABLE);
}
示例11: onCreate
import android.database.DatabaseUtils; //導入方法依賴的package包/類
@Override
public void onCreate(@NonNull SQLiteDatabase db) {
String CREATE_BOOKMARK_TABLE = "CREATE TABLE " +
DatabaseUtils.sqlEscapeString(TABLE_BOOKMARK) + '(' +
DatabaseUtils.sqlEscapeString(KEY_ID) + " INTEGER PRIMARY KEY," +
DatabaseUtils.sqlEscapeString(KEY_URL) + " TEXT," +
DatabaseUtils.sqlEscapeString(KEY_TITLE) + " TEXT," +
DatabaseUtils.sqlEscapeString(KEY_FOLDER) + " TEXT," +
DatabaseUtils.sqlEscapeString(KEY_POSITION) + " INTEGER" + ')';
db.execSQL(CREATE_BOOKMARK_TABLE);
}
示例12: searchFood
import android.database.DatabaseUtils; //導入方法依賴的package包/類
/**
* Searches for MyFood by their name and brand given a query.
* @param search Search query to filter results by
* @param count Maximum number of results to return
* @return
*/
public ArrayList<MyFood> searchFood(String search, final int count) {
search = "%" + search.replace(" ", "%") + "%";
final String escSearch = DatabaseUtils.sqlEscapeString(search);
final String query = "SELECT *" +
" FROM " + SQLiteHelper.Table_Food +
" WHERE name || ' ' || brand LIKE " + escSearch +
" OR brand || ' ' || name LIKE " + escSearch +
" LIMIT " + count;
Cursor results = database.rawQuery(query, null);
return instantiateFoodList(results);
}
示例13: escapeString
import android.database.DatabaseUtils; //導入方法依賴的package包/類
private String escapeString(String text){
text = DatabaseUtils.sqlEscapeString(text);
StringBuilder text_sb = new StringBuilder(text);
if(text_sb.charAt(0) == ('\'')){
text_sb = text_sb.deleteCharAt(0);
}
if(text_sb.charAt(text_sb.length() - 1) == ('\'')){
text_sb = text_sb.deleteCharAt(text_sb.length() - 1);
}
return text_sb.toString();
}
示例14: isContainsRoomMember
import android.database.DatabaseUtils; //導入方法依賴的package包/類
@Override
public boolean isContainsRoomMember(int roomId, String email) {
String query = "SELECT * FROM "
+ QiscusDb.RoomMemberTable.TABLE_NAME + " WHERE "
+ QiscusDb.RoomMemberTable.COLUMN_ROOM_ID + " = " + roomId + " "
+ "AND " + QiscusDb.RoomMemberTable.COLUMN_USER_EMAIL
+ " = " + DatabaseUtils.sqlEscapeString(email);
Cursor cursor = sqLiteDatabase.rawQuery(query, null);
boolean contains = cursor.getCount() > 0;
cursor.close();
return contains;
}
示例15: deleteRoomMember
import android.database.DatabaseUtils; //導入方法依賴的package包/類
@Override
public void deleteRoomMember(int roomId, String email) {
String where = QiscusDb.RoomMemberTable.COLUMN_ROOM_ID + " = " + roomId + " "
+ "AND " + QiscusDb.RoomMemberTable.COLUMN_USER_EMAIL + " = " + DatabaseUtils.sqlEscapeString(email);
sqLiteDatabase.beginTransaction();
try {
sqLiteDatabase.delete(QiscusDb.RoomMemberTable.TABLE_NAME, where, null);
sqLiteDatabase.setTransactionSuccessful();
} catch (Exception e) {
e.printStackTrace();
} finally {
sqLiteDatabase.endTransaction();
}
}