parcelable - How to marshal/unmarshal ContentValues to insert generic type into ContentProvider? -


I want to put a general POO in ContentValues ​​and open it within ContentProvider.

I am finishing my little brain again: Inserting Parasabal, Content Value, and SQLite:

I have added Android I am trying. Location in SQLite via ContentProvider:

  location loc = mLocationClient.getLastLocation (); MyParcel = android.os.Parcel.obtain (); Loc.writeToParcel (myParcel, 0); Content value = content value Crater. Secret Parsel (myParcel); Question 1) This is my ContentProvider.insert method:  
  Insert the public URI @Override (last Uri Uri, the value of the final content values) { SQLiteDatabase db = Mydatabase.getWritableDatabase (); //db.insert () What values ​​do not disagree ?? Db.insert (myTABLE_NAME, a ???? one ????, value); Ure result = null; Db.close (); Return result; }   

This fails because db.insert () does not disagree values ​​(I believe) and error entering android.database.sqlite.SQLiteException: myTABLE_NAME () in VALUES (NULL) )

Question 2) Is there any way I can add values ​​first and then change it to another content value? Maybe w / getKey () ???

This works:

  Hashmap HM = new Hashmap ( ); Location people = mLocationClient.getLastLocation (); Hm.put ("LOCATIONS", location); Android.os.Parcel myParcel = android.os.Parcel.obtain (); MyParcel.writeMap (hm); MyParcel.setDataPosition (0); Content value = content value Crater. Secret Parsel (myParcel); GetContentResolver () Insert (MyUri, Value); Enter   

and then

  @ override public (last Uri Yuri, last content value, old attribute) {SQLiteDatabase db = GAELdatabase.getWritableDatabase (); Ure result = null; Location people = (location) oldvalues.get ("LOCATIONS"); Material values ​​= new material value (); Values.put ("ALTITUDE", loc.getAltitude ()); // meters above sea level values. Input ("latitude", public.Getlightitude ()); Values.put ("LONGITUDE", loc.getLongitude ()); Long rowID = db.insert ("MyTABLE_NAME", "", value); Db.close (); Return result; }    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -