Home > DeveloperSection > Forums > How to convert string to char array using java
Ankit Singh

Total Post:341

Points:2389
Posted on    October-14-2013 3:33 AM

 Java Java 
Ratings:


 1 Reply(s)
 811  View(s)
Rate this:

Is there a way in which a string "hello" can be changed into a 'hello' in java (android)?? This is to make my sql query work. For example

public Cursor GetLecture(String course_code)
{
    SQLiteDatabase sqldb = this.getReadableDatabase();
    String query = "SELECT * FROM Lecture WHERE course_code =" + course_code;
    Cursor C = sqldb.rawQuery(query, null);
    return C;
}


Hank Greenberg
Hank Greenberg

Total Post:12

Points:84
Posted on    October-14-2013 3:53 AM

Strings are sequence of characters delimited by double quotes. You can't delimit them by single quotes. Those are for characters. This one is in Java.

In case of SQL query, to enclose your string in single quotes, you can do it like this:

String query = "SELECT * FROM Lecture WHERE course_code = '" + course_code + "'";

Don't want to miss updates? Please click the below button!

Follow MindStick