问题
I have a problem with SQLite and android, I`m trying to select arabic data from the db, the db filled by the data outside android and i push it to android emulator.. the english text appears normaly but the arabic text appear in wrong way
the text appears like this img
so help me plz
回答1:
I checked with Arabic database with random text created via code:
db = openOrCreateDatabase("dictionary", MODE_PRIVATE, null);
db.execSQL("CREATE TABLE IF NOT EXISTS LIST(wlist varchar);");
db.execSQL("INSERT INTO LIST VALUES('صبالخير');");
db.execSQL("INSERT INTO LIST VALUES('صبا لخير');");
Then I used following query with cursor to dynamically select text from database:
String q = "SELECT * FROM LIST";
Cursor c = db.rawQuery(q, null);
if(c.getCount() == 0)
{
setSuggestions(list, true, true);
}
else{
int i=0;
c.moveToFirst();
do {
String cm = c.getString(c.getColumnIndex("wlist"));
list.add(cm);
i++;
} while (c.moveToNext() && i<30);
The result is as follows:

Arabic text is shown. So, check your existing database with a SQLite Database Browser if Arabic data is in correct form there.
来源:https://stackoverflow.com/questions/10518409/bad-result-with-encoding-when-selecting-arabic-data-from-sqlite-android