GreenDao 直接执行SQL的方法

try
                {
                    DaoSession session=MyApplication.getInstances().getDaoSession();
                    long fromId=-1;
                    String strSql="select * from test order by ID desc limit 0,1 ";
                    Cursor c  = session.getDatabase().rawQuery(strSql,null);
                    if(c.moveToFirst())
                    {
                        fromId=c.getLong(c.getColumnIndex("ID"));

                    }
                    c.close();
                }
                catch (Exception ex)
                {
                    showToast(ex.getMessage());
                }

 

转载于:https://www.cnblogs.com/zhaogaojian/p/9777657.html

你可能感兴趣的:(GreenDao 直接执行SQL的方法)