Autore Topic: Update Content Provider  (Letto 758 volte)

Offline tanuccio85

  • Nuovo arrivato
  • *
  • Post: 34
  • Respect: 0
    • Mostra profilo
Update Content Provider
« il: 21 Aprile 2011, 16:10:35 CEST »
0
Salve ragazzi ho un problema è non so proprio come risolverlo logicamente
Ho creato un mio Content Provider con delle informazioni su un Db di parcheggi.
Quando visualizzo la mappa e clicco sul marcatore del Parcheggio mi visualizza tutte le informazioni del parcheggio in particolare i posti disponibili.
Poi cliccando su un positiveButton di un AlertDialog mi decrementa il numero di posti disponibili del parcheggio.
Ora il mio problema stà nell'aggiornare il Content Provider con il numero di posti decrementato.
Qualcuno sà come aiutarmi????


ho provato a fare così ma mi crasha
Codice (Java): [Seleziona]
private final static Uri PARK_TEAM_URI = Uri.parse("content://com.simpleprovider.SimpleProvider/park");

protected boolean onTap(int i) {
                //OverlayItem item = parcheggi.get(i);
               
          AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
          dialog.setTitle("Parcheggi Salerno");
          dialog.setIcon(R.drawable.parcheggio);//setta l'iconcina
          //dialog.setMessage(ind);
          dialog.setMessage(nome+"\n"+"Indirizzo: "+"\n"+ind+"\n"+"Posti: "+"\n"+Integer.toString(pos_lib)+"/"+Integer.toString(n_posti)+"\n"+"Costo: "+"\n"+Double.toString(costo)+"€");
          dialog.setPositiveButton("Prenota", new DialogInterface.OnClickListener() {
               
                @Override
                public void onClick(DialogInterface dialog, int which) {
                        // TODO Auto-generated method stub
                        if(pos_lib!=0)
                        {
                                        pos_lib--;
                                        //Qui bisognerebbe aggiornare il Content Provider
                                       
                                        ContentValues cValues=new ContentValues();
                                        [b]cValues.put(Integer.toString(pos_lib),ParkMetaData.POSTI_LIBERI);[/b]
                                        String selection = ParkMetaData.INDIRIZZO+ "= ?";
                                        String[] selectionArgs = { ind };
                                        mContext.getContentResolver().update(PARK_TEAM_URI, cValues, selection, selectionArgs);
                                       
                        }
                        else{
                                AlertDialog.Builder dialog2 = new AlertDialog.Builder(mContext);
                                  dialog2.setTitle("Parcheggi Salerno");
                                  dialog2.setIcon(R.drawable.alert_icon);//setta l'iconcina
                                  dialog2.setMessage("Parcheggio Completo");
                                  dialog2.setPositiveButton(R.string.ok,null);
                                  dialog2.show();
                        }
                }
          });
          dialog.setNegativeButton("Annulla", null);
          dialog.show();
          return (true);

}


ecco il LogCat

Codice (Java): [Seleziona]
04-21 21:34:50.027: ERROR/BatteryService(58): usbOnlinePath not found
04-21 21:34:50.027: ERROR/BatteryService(58): batteryVoltagePath not found
04-21 21:34:50.027: ERROR/BatteryService(58): batteryTemperaturePath not found
04-21 21:34:50.048: ERROR/SurfaceFlinger(58): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
04-21 21:34:56.737: ERROR/EventHub(58): could not get driver version for /dev/input/mouse0, Not a typewriter
04-21 21:34:56.737: ERROR/EventHub(58): could not get driver version for /dev/input/mice, Not a typewriter
04-21 21:34:57.027: ERROR/System(58): Failure starting core service
04-21 21:34:57.027: ERROR/System(58): java.lang.SecurityException
04-21 21:34:57.027: ERROR/System(58):     at android.os.BinderProxy.transact(Native Method)
04-21 21:34:57.027: ERROR/System(58):     at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
04-21 21:34:57.027: ERROR/System(58):     at android.os.ServiceManager.addService(ServiceManager.java:72)
04-21 21:34:57.027: ERROR/System(58):     at com.android.server.ServerThread.run(SystemServer.java:176)
04-21 21:34:57.047: ERROR/AndroidRuntime(58): Crash logging skipped, no checkin service
04-21 21:35:09.001: ERROR/ActivityThread(101): Failed to find provider info for android.server.checkin
04-21 21:35:11.782: ERROR/ActivityThread(101): Failed to find provider info for android.server.checkin
04-21 21:35:11.921: ERROR/ActivityThread(101): Failed to find provider info for android.server.checkin
04-21 21:35:12.942: ERROR/vold(26): Cannot start volume '
/sdcard' (volume is not bound)
04-21 21:35:13.322: ERROR/MediaPlayerService(30): Couldn'
t open fd for content://settings/system/notification_sound
04-21 21:35:13.322: ERROR/MediaPlayer(58): Unable to to create media player
04-21 21:35:19.502: ERROR/AndroidRuntime(128): ERROR: thread attach failed
04-21 21:35:30.703: ERROR/AndroidRuntime(180): ERROR: thread attach failed
04-21 21:35:31.153: ERROR/ActivityThread(58): Failed to find provider info for com.google.settings
04-21 21:35:31.153: ERROR/ActivityThread(58): Failed to find provider info for com.google.settings
04-21 21:35:31.823: ERROR/ActivityThread(221): Failed to find provider info for com.google.settings
04-21 21:35:31.823: ERROR/ActivityThread(221): Failed to find provider info for com.google.settings
04-21 21:35:31.893: ERROR/ActivityThread(221): Failed to find provider info for com.google.settings
04-21 21:35:33.523: ERROR/MapActivity(221): Couldn't get connection factory client
04-21 21:37:07.274: ERROR/AndroidRuntime(251): ERROR: thread attach failed
04-21 21:37:10.643: ERROR/AndroidRuntime(262): ERROR: thread attach failed
04-21 21:37:11.663: ERROR/ActivityThread(269): Failed to find provider info for com.google.settings
04-21 21:37:11.673: ERROR/ActivityThread(269): Failed to find provider info for com.google.settings
04-21 21:37:11.703: ERROR/ActivityThread(269): Failed to find provider info for com.google.settings
04-21 21:37:12.323: ERROR/MapActivity(269): Couldn'
t get connection factory client
04-21 21:37:23.733: ERROR/ActivityThread(269): Failed to find provider info for com.google.settings
04-21 21:37:23.743: ERROR/ActivityThread(269): Failed to find provider info for com.google.settings
04-21 21:37:24.834: ERROR/MapActivity(269): Couldn't get connection factory client
04-21 21:37:30.823: ERROR/Database(234): Error updating 14=posti_liberi using UPDATE PARK SET 14=? WHERE indirizzo= ?
04-21 21:37:31.023: ERROR/DatabaseUtils(234): Writing exception to parcel
04-21 21:37:31.023: ERROR/DatabaseUtils(234): android.database.sqlite.SQLiteException: near "14": syntax error: , while compiling: UPDATE PARK SET 14=? WHERE indirizzo= ?
04-21 21:37:31.023: ERROR/DatabaseUtils(234):     at android.database.sqlite.SQLiteProgram.native_compile(Native Method)
04-21 21:37:31.023: ERROR/DatabaseUtils(234):     at android.database.sqlite.SQLiteProgram.compile(SQLiteProgram.java:110)
04-21 21:37:31.023: ERROR/DatabaseUtils(234):     at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59)
04-21 21:37:31.023: ERROR/DatabaseUtils(234):     at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:41)
04-21 21:37:31.023: ERROR/DatabaseUtils(234):     at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1026)
04-21 21:37:31.023: ERROR/DatabaseUtils(234):     at android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1555)
04-21 21:37:31.023: ERROR/DatabaseUtils(234):     at android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:1499)
04-21 21:37:31.023: ERROR/DatabaseUtils(234):     at com.simpleprovider.SimpleProvider.update(SimpleProvider.java:312)
04-21 21:37:31.023: ERROR/DatabaseUtils(234):     at android.content.ContentProvider$Transport.update(ContentProvider.java:180)
04-21 21:37:31.023: ERROR/DatabaseUtils(234):     at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:195)
04-21 21:37:31.023: ERROR/DatabaseUtils(234):     at android.os.Binder.execTransact(Binder.java:287)
04-21 21:37:31.023: ERROR/DatabaseUtils(234):     at dalvik.system.NativeStart.run(Native Method)
04-21 21:37:31.053: ERROR/AndroidRuntime(269): Uncaught handler: thread main exiting due to uncaught exception
04-21 21:37:31.063: ERROR/AndroidRuntime(269): android.database.sqlite.SQLiteException: near "14": syntax error: , while compiling: UPDATE PARK SET 14=? WHERE indirizzo= ?
04-21 21:37:31.063: ERROR/AndroidRuntime(269):     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:158)
04-21 21:37:31.063: ERROR/AndroidRuntime(269):     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)
04-21 21:37:31.063: ERROR/AndroidRuntime(269):     at android.content.ContentProviderProxy.update(ContentProviderNative.java:532)
04-21 21:37:31.063: ERROR/AndroidRuntime(269):     at android.content.ContentResolver.update(ContentResolver.java:737)
04-21 21:37:31.063: ERROR/AndroidRuntime(269):     at com.prova.ParcheggiSalernoOverlay$1.onClick(ParcheggiSalernoOverlay.java:87)
04-21 21:37:31.063: ERROR/AndroidRuntime(269):     at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:158)
04-21 21:37:31.063: ERROR/AndroidRuntime(269):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-21 21:37:31.063: ERROR/AndroidRuntime(269):     at android.os.Looper.loop(Looper.java:123)
04-21 21:37:31.063: ERROR/AndroidRuntime(269):     at android.app.ActivityThread.main(ActivityThread.java:4363)
04-21 21:37:31.063: ERROR/AndroidRuntime(269):     at java.lang.reflect.Method.invokeNative(Native Method)
04-21 21:37:31.063: ERROR/AndroidRuntime(269):     at java.lang.reflect.Method.invoke(Method.java:521)
04-21 21:37:31.063: ERROR/AndroidRuntime(269):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-21 21:37:31.063: ERROR/AndroidRuntime(269):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-21 21:37:31.063: ERROR/AndroidRuntime(269):     at dalvik.system.NativeStart.main(Native Method)
04-21 21:37:38.653: ERROR/ActivityThread(285): Failed to find provider info for com.google.settings
04-21 21:37:38.663: ERROR/ActivityThread(285): Failed to find provider info for com.google.settings
04-21 21:37:38.683: ERROR/ActivityThread(285): Failed to find provider info for com.google.settings
04-21 21:37:39.283: ERROR/MapActivity(285): Couldn'
t get connection factory client
04-21 21:41:20.163: ERROR/AndroidRuntime(297): ERROR: thread attach failed
04-21 21:41:23.543: ERROR/AndroidRuntime(308): ERROR: thread attach failed
04-21 21:41:24.533: ERROR/ActivityThread(314): Failed to find provider info for com.google.settings
04-21 21:41:24.543: ERROR/ActivityThread(314): Failed to find provider info for com.google.settings
04-21 21:41:24.583: ERROR/ActivityThread(314): Failed to find provider info for com.google.settings
04-21 21:41:25.373: ERROR/MapActivity(314): Couldn't get connection factory client
04-21 21:41:34.753: ERROR/ActivityThread(314): Failed to find provider info for com.google.settings
04-21 21:41:34.763: ERROR/ActivityThread(314): Failed to find provider info for com.google.settings
04-21 21:41:35.703: ERROR/MapActivity(314): Couldn'
t get connection factory client
04-21 21:41:41.953: ERROR/AndroidRuntime(314): Uncaught handler: thread main exiting due to uncaught exception
04-21 21:41:41.963: ERROR/AndroidRuntime(314): java.lang.NullPointerException
04-21 21:41:41.963: ERROR/AndroidRuntime(314):     at android.content.ContentProviderProxy.update(ContentProviderNative.java:526)
04-21 21:41:41.963: ERROR/AndroidRuntime(314):     at android.content.ContentResolver.update(ContentResolver.java:737)
04-21 21:41:41.963: ERROR/AndroidRuntime(314):     at com.prova.ParcheggiSalernoOverlay$1.onClick(ParcheggiSalernoOverlay.java:87)
04-21 21:41:41.963: ERROR/AndroidRuntime(314):     at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:158)
04-21 21:41:41.963: ERROR/AndroidRuntime(314):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-21 21:41:41.963: ERROR/AndroidRuntime(314):     at android.os.Looper.loop(Looper.java:123)
04-21 21:41:41.963: ERROR/AndroidRuntime(314):     at android.app.ActivityThread.main(ActivityThread.java:4363)
04-21 21:41:41.963: ERROR/AndroidRuntime(314):     at java.lang.reflect.Method.invokeNative(Native Method)
04-21 21:41:41.963: ERROR/AndroidRuntime(314):     at java.lang.reflect.Method.invoke(Method.java:521)
04-21 21:41:41.963: ERROR/AndroidRuntime(314):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-21 21:41:41.963: ERROR/AndroidRuntime(314):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-21 21:41:41.963: ERROR/AndroidRuntime(314):     at dalvik.system.NativeStart.main(Native Method)
04-21 21:41:45.623: ERROR/ActivityThread(329): Failed to find provider info for com.google.settings
04-21 21:41:45.634: ERROR/ActivityThread(329): Failed to find provider info for com.google.settings
04-21 21:41:45.663: ERROR/ActivityThread(329): Failed to find provider info for com.google.settings
04-21 21:41:46.554: ERROR/MapActivity(329): Couldn't get connection factory client
04-21 21:42:51.854: ERROR/AndroidRuntime(339): ERROR: thread attach failed
04-21 21:42:55.463: ERROR/AndroidRuntime(350): ERROR: thread attach failed
04-21 21:42:56.384: ERROR/ActivityThread(356): Failed to find provider info for com.google.settings
04-21 21:42:56.393: ERROR/ActivityThread(356): Failed to find provider info for com.google.settings
04-21 21:42:56.434: ERROR/ActivityThread(356): Failed to find provider info for com.google.settings
04-21 21:42:57.094: ERROR/MapActivity(356): Couldn'
t get connection factory client
04-21 21:43:06.883: ERROR/ActivityThread(356): Failed to find provider info for com.google.settings
04-21 21:43:06.893: ERROR/ActivityThread(356): Failed to find provider info for com.google.settings
04-21 21:43:07.863: ERROR/MapActivity(356): Couldn't get connection factory client
04-21 21:43:13.464: ERROR/Database(234): Error updating 14=posti_liberi using UPDATE PARK SET 14=? WHERE indirizzo= ?
04-21 21:43:13.473: ERROR/DatabaseUtils(234): Writing exception to parcel
04-21 21:43:13.473: ERROR/DatabaseUtils(234): android.database.sqlite.SQLiteException: near "14": syntax error: , while compiling: UPDATE PARK SET 14=? WHERE indirizzo= ?
04-21 21:43:13.473: ERROR/DatabaseUtils(234):     at android.database.sqlite.SQLiteProgram.native_compile(Native Method)
04-21 21:43:13.473: ERROR/DatabaseUtils(234):     at android.database.sqlite.SQLiteProgram.compile(SQLiteProgram.java:110)
04-21 21:43:13.473: ERROR/DatabaseUtils(234):     at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59)
04-21 21:43:13.473: ERROR/DatabaseUtils(234):     at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:41)
04-21 21:43:13.473: ERROR/DatabaseUtils(234):     at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1026)
04-21 21:43:13.473: ERROR/DatabaseUtils(234):     at android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1555)
04-21 21:43:13.473: ERROR/DatabaseUtils(234):     at android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:1499)
04-21 21:43:13.473: ERROR/DatabaseUtils(234):     at com.simpleprovider.SimpleProvider.update(SimpleProvider.java:312)
04-21 21:43:13.473: ERROR/DatabaseUtils(234):     at android.content.ContentProvider$Transport.update(ContentProvider.java:180)
04-21 21:43:13.473: ERROR/DatabaseUtils(234):     at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:195)
04-21 21:43:13.473: ERROR/DatabaseUtils(234):     at android.os.Binder.execTransact(Binder.java:287)
04-21 21:43:13.473: ERROR/DatabaseUtils(234):     at dalvik.system.NativeStart.run(Native Method)
04-21 21:43:13.514: ERROR/AndroidRuntime(356): Uncaught handler: thread main exiting due to uncaught exception
04-21 21:43:13.524: ERROR/AndroidRuntime(356): android.database.sqlite.SQLiteException: near "14": syntax error: , while compiling: UPDATE PARK SET 14=? WHERE indirizzo= ?
04-21 21:43:13.524: ERROR/AndroidRuntime(356):     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:158)
04-21 21:43:13.524: ERROR/AndroidRuntime(356):     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)
04-21 21:43:13.524: ERROR/AndroidRuntime(356):     at android.content.ContentProviderProxy.update(ContentProviderNative.java:532)
04-21 21:43:13.524: ERROR/AndroidRuntime(356):     at android.content.ContentResolver.update(ContentResolver.java:737)
04-21 21:43:13.524: ERROR/AndroidRuntime(356):     at com.prova.ParcheggiSalernoOverlay$1.onClick(ParcheggiSalernoOverlay.java:87)
04-21 21:43:13.524: ERROR/AndroidRuntime(356):     at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:158)
04-21 21:43:13.524: ERROR/AndroidRuntime(356):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-21 21:43:13.524: ERROR/AndroidRuntime(356):     at android.os.Looper.loop(Looper.java:123)
04-21 21:43:13.524: ERROR/AndroidRuntime(356):     at android.app.ActivityThread.main(ActivityThread.java:4363)
04-21 21:43:13.524: ERROR/AndroidRuntime(356):     at java.lang.reflect.Method.invokeNative(Native Method)
04-21 21:43:13.524: ERROR/AndroidRuntime(356):     at java.lang.reflect.Method.invoke(Method.java:521)
04-21 21:43:13.524: ERROR/AndroidRuntime(356):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-21 21:43:13.524: ERROR/AndroidRuntime(356):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-21 21:43:13.524: ERROR/AndroidRuntime(356):     at dalvik.system.NativeStart.main(Native Method)
04-21 21:43:16.663: ERROR/ActivityThread(373): Failed to find provider info for com.google.settings
04-21 21:43:16.674: ERROR/ActivityThread(373): Failed to find provider info for com.google.settings
04-21 21:43:16.724: ERROR/ActivityThread(373): Failed to find provider info for com.google.settings
04-21 21:43:17.403: ERROR/MapActivity(373): Couldn'
t get connection factory client


l'errore stava quando andavo a chiamare il metodo put() dove avevo scambiato key e values
Grazie
« Ultima modifica: 22 Aprile 2011, 00:35:08 CEST da tanuccio85 »