从SQLite& ...选择阿拉伯数据时,编码结果不良安卓 [英] Bad result with encoding when Selecting arabic data from SQLite & android
问题描述
我试图从数据库中选择阿拉伯数据,数据库由android外的数据填充,并将其推送到android模拟器。
英文文本显示正常,但阿拉伯语文本出现错误的方式
文本显示为这个img
所以帮我plz
我用阿拉伯数据库检查了通过代码创建的随机文本:
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('صبالخير'););
然后我用游标使用以下查询动态地从数据库中选择文本:
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);
结果如下:
显示阿拉伯文字。所以,如果阿拉伯数据是正确的形式,请使用SQLite数据库浏览器检查现有的数据库。
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
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.
这篇关于从SQLite& ...选择阿拉伯数据时,编码结果不良安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!