Skip to content Skip to sidebar Skip to footer

Bad Result With Encoding When Selecting Arabic Data From Sqlite & Android

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 te

Solution 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:

Stringq="SELECT * FROM LIST";
Cursorc= db.rawQuery(q, null);
if(c.getCount() == 0)
  {
    setSuggestions(list, true, true);
  }
else{
  int i=0;
  c.moveToFirst();
     do {
         Stringcm= c.getString(c.getColumnIndex("wlist")); 
                      list.add(cm);
                      i++;
        } while (c.moveToNext() && i<30);      

The result is as follows:

enter image description here Arabic text is shown. So, check your existing database with a SQLite Database Browser if Arabic data is in correct form there.

Post a Comment for "Bad Result With Encoding When Selecting Arabic Data From Sqlite & Android"