Chinese There is a province name of the database , which should be put GBK encoded Chinese province name data .
SQL statement does not contain Chinese , press the following code to read the Chinese names :
SQLiteDatabase mSQLiteDatabase = null;
mSQLiteDatabase = SQLiteDatabase.openDatabase ("mnt / sdcard / MyProject / placeName.db", null, SQLiteDatabase.OPEN_READONLY);
String sql = "SELECT * FROM T_Province";
Cursor cur = mSQLiteDatabase.rawQuery (sql, null);
. . . . Such information can be queried to
String sql = "SELECT * FROM T_Province where ID <10" ;/ / this can also query the information
String sql = "SELECT * FROM T_Province where Name = ' Beijing '" ;/ / This will not query any records
ask for advice god
------ Solution --------------------------------- -----------
I use sqlite Database browser tool tried, can be found ah. . . .
field type is text. .
Android next not tried.
------ eference --------------------------------------- < br> query to the Chinese portion can be transcoded displayed correctly :
int num = cur.getColumnIndex ("Name");
byte [] val = cur.getBlob (num);
String placeName = "";
try {
placeName = new String (val, "gb3212");
}
catch (UnsupportedEncodingException e)
{
e.printStackTrace ();
}
so placeName which is not a normal Chinese garbled , but the SQL statement containing Chinese will not query any records in the SQL statement when the need for splicing transcoding do ? Find Great God enlighten
------ eference ------------------------------------- -
own support you , find great God appeared
------ eference --------------------------- ------------
Thank you, my problem has been resolved.
Windows ANSI encoding used by default under , while Android and IOS defaults to using UTF-8 encoding , so utf-8 encoded database in the windows read out is garbled, while ANSI encoded database on Android and IOS on the read out is garbled .
I use SQLite Expert software to import Excel data tables to generate a new database utf-8 format , it can be used directly on the Android without transcoding , and this way the SQL statement can contain not only Chinese You can also support fuzzy queries
As for side windows also continue to use the database before the ANSI encoding like
没有评论:
发表评论