java - Android Sqlite update last record using string from JNI -


i have app measures distance between colored circles in live camera feed. i'm able string jni here. now, want save string database can't make work.

this db helper class:

public class databasehelperuback extends sqliteopenhelper {      public static final string database_name="ubackrecords.db";     public static final string table_name="records_table";     public static final string col_0="id";     public static final string col_1="uback";      public databasehelperuback(context context) {         super(context, database_name, null, 1);       }      @override     public void oncreate(sqlitedatabase db) {         db.execsql("create table " + table_name + " (id integer primary key autoincrement, uback text) ");     }      @override     public void onupgrade(sqlitedatabase db, int oldversion, int newversion) {         db.execsql("drop table if exist "+table_name);     }       //public boolean insertdata(string name, string date_today, string sleeve, string shoulder, string body_length, string cross_back, string bw_length, string bn_cuff, string inseam, string outseam){      public boolean insertdata(string uback){          sqlitedatabase db=this.getwritabledatabase();          contentvalues contentvalues = new contentvalues();         contentvalues.put(col_1,uback);          long result = db.insert(table_name, null, contentvalues);          if(result == -1)             return false;         else             return true;      }      public boolean updatedata(string id, string uback){          sqlitedatabase db=this.getwritabledatabase();          contentvalues contentvalues = new contentvalues();         contentvalues.put(col_0,id);         contentvalues.put(col_1,uback);          db.update(table_name, contentvalues, "id = ?", new string[] { id } );              return true;      }      public cursor getalldata(){          sqlitedatabase db=this.getwritabledatabase();          cursor res = db.rawquery("select * "+table_name,null);         return res;      }   } 

i made work on following class made work id=1 of table. not know how retrieve last row of table 1 updated/replaced (because live camera feed).

public class ubacktrackviewer extends sampleviewbase{       databasehelperuback mydb;      private context mcontext;      private int mframesize;     private bitmap mbitmap;     private int[] mrgba;       public ubacktrackviewer(context context) {         super(context);          this.mcontext = context;          mydb = new databasehelperuback(mcontext);     }       public string messageme2(string text) {         system.out.println(text);          mydb.updatedata("1", text);          return text;     }        @override     public boolean ontouchevent(motionevent event){          switch (event.getaction()) {             case motionevent.action_down:                  mydb.insertdata("");       }       static {         system.loadlibrary("objtrack_opencv_jnii_uback");     }        @override     protected void onpreviewstared(int previewwidtd, int previewheight) {         mframesize = previewwidtd * previewheight;         mrgba = new int[mframesize];         mbitmap = bitmap.createbitmap(previewwidtd, previewheight, bitmap.config.argb_8888);     }       @override     protected void onpreviewstopped() {         if(mbitmap != null) {             mbitmap.recycle();             mbitmap = null;         }         mrgba = null;      }        @override     protected bitmap processframe(byte[] data) {         int[] rgba = mrgba;          ubackobjecttrack(getframewidth(), getframeheight(), data, rgba, loweractivity.bshowtresholded);          //returnuback3(getframewidth(), getframeheight(), data, rgba, loweractivity.bshowtresholded);        // returnuback(getframewidth(), getframeheight(), data, rgba, loweractivity.bshowtresholded);         //returnuback2(getframewidth(), getframeheight(), data, rgba, loweractivity.bshowtresholded);          bitmap bmp = mbitmap;         bmp.setpixels(rgba, 0/* offset */, getframewidth() /* stride */, 0, 0, getframewidth(), getframeheight());         return bmp;     }      //public native void returnuback(int width, int height, byte yuv[], int[] rgba, boolean debug);    // public native void returnuback2(int width, int height, byte yuv[], int[] rgba, boolean debug);     //public native void returnuback3(int width, int height, byte yuv[], int[] rgba, boolean debug);      public native void ubackobjecttrack(int width, int height, byte yuv[], int[] rgba, boolean debug);      public native string ubackobjecttrack();      static {         system.loadlibrary("objtrack_opencv_jnii_uback");     } } 


Comments