Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I get accounthead title names from user and insert them in table after verifying its existance already. If already existed I just inform the user that it already exists and try some other title. But, For example, if the table already has a name like 'building'
and if the user again enters as 'Building' (first letter upper case'B") it is accepting. This has to be avoided.

public long insertData(String name) {
SQLiteDatabase db = helper.getWritableDatabase();
ContentValues contentvalues = new ContentValues();
contentvalues.put(VivzHelper.NAME, name);
long id = db.insert(VivzHelper.TABLE_NAME, null, contentvalues);
return id;
}


In the following code I search for existance:
public String getData(String sub1) {

SQLiteDatabase db = helper.getWritableDatabase();
String[] columns = new String[]{VivzHelper.NAME};
String[] selectionArgs = {sub1};
Cursor cursor = db.query(VivzHelper.TABLE_NAME, columns, VivzHelper.NAME+" =?",
selectionArgs, null,null,null);
StringBuffer buffer = new StringBuffer();
while(cursor.moveToNext())
{
int accountNameIDX=cursor.getColumnIndex(VivzHelper.NAME);
String accountName=cursor.getString(accountNameIDX);
buffer.append(accountName +"\n");
}
cursor.close();
if (buffer.toString().equals(""))
{
existsYesorNo="N";
}
else
{
existsYesorNo="Y";
}
return buffer.toString();
}
Posted
Updated 16-Mar-15 20:06pm
v2

1 solution

Use COLLATE for e.g. SELECT * FROM table COLLATE NOCASE
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900