0

我有一个微调器名称床,其值为 1,2,3,4,由另一个类文件获取,并且选定的项目被发送到数据库知道数据库返回的数据类似于选定的微调器值。知道此代码工作得很好对我来说
,将床的微调器值传递给另一个类的代码

             Intent i= new Intent(SearchByBed.this,SearchBedView.class);
             Bundle bbed= new Bundle();
             bbed.putString("bedValue", spinn_Bed.getSelectedItem().toString());
             i.putExtras(bbed);
             startActivity(i);

接收微调器值并将其发送到数据库的代码

           Bundle bbedview = this.getIntent().getExtras();
           String name = bbedview.getString("bedValue");
           cursor = info.getBed(name);

db 中执行搜索和返回值的代码

      public Cursor getBed(String l) {
      String[] columns = new String[] { KEY_ROWID, KEY_TITLE, KEY_TYPE,
      KEY_BEDROOMS, KEY_STATUS, KEY_CITY, KEY_LOCALITY, KEY_PRICE,
      KEY_TOTPRICE, KEY_FURNISHING, KEY_BALCONIES, KEY_BATHROOM };
      Cursor c = ourDatabase.query(DATABASE_TABLE, columns,    
          KEY_BEDROOMS + "=" + l, null, null, null, null);
      return c;}

知道我用于微调器名称类型的类似代码

String[] propertyType = { "Residental Apartment","Independent House/Villa", "Shops", "Agricultural/Farm Land" };
Intent i = new Intent(SearchByPropType.this,SearchPropView.class);
Bundle bprop = new Bundle();
bprop.putString("property", spinn_PropType.getSelectedItem().toString());
i.putExtras(bprop);
startActivity(i);

Bundle bprop = this.getIntent().getExtras();
String property = bprop.getString("property");

public Cursor getProperty(String n) {
String[] columns = new String[] { KEY_ROWID, KEY_TITLE, 
KEY_TYPE, KEY_BEDROOMS, KEY_STATUS, KEY_CITY, 
KEY_LOCALITY, KEY_PRICE, KEY_TOTPRICE, KEY_FURNISHING,
KEY_BALCONIES, KEY_BATHROOM };
Cursor c = ourDatabase.query(DATABASE_TABLE, columns,
 KEY_TYPE + "=" + n, null, null, null, null);
return c;}  

但是对于另一个值为“住宅公寓”、“独立住宅/别墅”、“商店”的微调器名称类型,我正在执行相同的过程
,但应用程序显示错误

04-30 21:12:11.296: E/AndroidRuntime(1585): FATAL EXCEPTION: main
04-30 21:12:11.296: E/AndroidRuntime(1585): android.database.sqlite.SQLiteException:    near "Apartment": syntax error (code 1): , while compiling: SELECT _id, property_title,     property_type, propety_bedroom, property_status, property_city, property_locality,  property_price, property_totprice, property_furnishing, property_balconies,     property_bathroom FROM propertymaster WHERE property_type=Residental    Apartment
04-30 21:12:11.296: E/AndroidRuntime(1585):     at  android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at  android.database.sqlite.SQLiteConnection.acquirePreparedStatement   (SQLiteConnection.java:882)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at  android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at      android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at  android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at android.database.sqlite.SQLiteQuery. <init>(SQLiteQuery.java:37)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at  android.database.sqlite.SQLiteDirectCursorDriver.query  (SQLiteDirectCursorDriver.java:44)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at  android.database.sqlite.SQLiteDatabase.rawQueryWithFactory  (SQLiteDatabase.java:1314)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at  android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1161)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at  android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1032)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at  android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1200)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at  com.project.realestate.PropertyInfo.getProperty(PropertyInfo.java:364)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at  com.project.realestate.SearchPropView.displaydemo(SearchPropView.java:303)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at  com.project.realestate.SearchPropView$loadSomeStuff.onPostExecute   (SearchPropView.java:279)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at  com.project.realestate.SearchPropView$loadSomeStuff.onPostExecute   (SearchPropView.java:1)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at android.os.AsyncTask.finish  (AsyncTask.java:631)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at android.os.AsyncTask.access$600  (AsyncTask.java:177)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at android.os.AsyncTask $InternalHandler.handleMessage(AsyncTask.java:644)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at android.os.Handler.dispatchMessage   (Handler.java:99)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at android.os.Looper.loop   (Looper.java:137)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at android.app.ActivityThread.main  (ActivityThread.java:5039)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at  java.lang.reflect.Method.invokeNative(Native Method)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at java.lang.reflect.Method.invoke  (Method.java:511)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at com.android.internal.os.ZygoteInit   $MethodAndArgsCaller.run(ZygoteInit.java:793)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-30 21:12:11.296: E/AndroidRuntime(1585):     at dalvik.system.NativeStart.main   (Native Method)
4

0 回答 0