Monday, March 3, 2014
When ANDROID development database fuzzy query Chinese, not seized, is how is it?
FoodAdditivesAppActivity.java to AccuratelySearch.java-value
Value and the acquired input value input box is correct,
However in the database search fuzzy search Chinese, unable to search.
The number of inquiries and English can be.
SQL statement:
sql = "Select name, norm From additive Where name Like '%" + value + "%'";
value is the value entered in the input box by log.e ("value", value) values correctly
incoming inspectionSQLITE database<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Database coding
Reply:
First look at the operation into sqllite
Reply:
This possibility, android applications top Chinese is utf coding, while the database is GBK, two encoding ASCII English and numbers are coming, coding, as can be found, is not the same character coding
Reply:
temp = new String (value.getBytes (), "UTF-8");
But I after transcoding in the database search as search less,
Have tried a variety of coding
Reply:
You can do all of the code Tieshanglai
Reply:
In the database are not received, the statement that there is a problem
Reply:
Generally do not have arguments, are used? On behalf of the variables, look grammar
Reply:
You can search the database in English, but found not Chinese.
Reply:
package com.Food.app;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import android.app.Activity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.widget.ListView;
import android.widget.SimpleAdapter;
public class AccuratelySearch extends Activity {
private SQLiteDatabase db;
private String sql, value, temp;
public void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.classfyresult);
db = SQLiteDatabase.openOrCreateDatabase (DBManager.DB_PATH + "/"
+ DBManager.DB_NAME, null);
value = (String) getIntent () getSerializableExtra ("value");.
try {
temp = new String (value.getBytes (), "UTF-8");
} Catch (UnsupportedEncodingException e1) {
/ / TODO Auto-generated catch block
e1.printStackTrace ();
}
sql = "Select name, norm From additive Where name Like '%" + temp + "%'";
/ / Check incoming values
Log.e ("sql", sql);
Cursor c = db.rawQuery (sql, null);
c.moveToFirst ();
ArrayList
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment