小编sec*_*ond的帖子

Orm Lite - 无法找到具有helper类的单个(Context)参数的公共构造函数

我正在使用OrmLite 4.47.我遵循了许多教程,并在stackoverflow上阅读了其他问题,但我无法理解如何解决这个问题.

这是完整的信息

05-15 16:36:13.805: E/AndroidRuntime(15382): Caused by: java.lang.IllegalStateException: Could not find public constructor that has a single (Context) argument for helper class class com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper
05-15 16:36:13.805: E/AndroidRuntime(15382): Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context]
Run Code Online (Sandbox Code Playgroud)

那是我的databaseHelper类

public class MyDatabaseHelper extends OrmLiteSqliteOpenHelper {  

    // name of the database file for your application -- change to something  
    // appropriate for your app  
    private static final String DATABASE_NAME = "databas.db";  
    // any time you make changes to your database, you may have to increase …
Run Code Online (Sandbox Code Playgroud)

android ormlite

8
推荐指数
2
解决办法
3510
查看次数

Android中使用ORMLITE的多个查询条件

我想做一个简单的查询,有多个条件

我使用OrmLite来映射实体对象.

现在我想在我的表中搜索一个对象.

假设我有一个映射PERSON表的Person实体,我想要做的是用一些参数初始化一个对象并搜索它.

假设一个功能 searchPerson(Person oPerson)

如果我像这样传递一个对象OPerson

Id = null
Name = John
Age = null
Sex = male
Run Code Online (Sandbox Code Playgroud)

是否可以编写查询以达到该目标?像这样的伪代码

pers = (from p in db.Table<Person>() 
                     where (if OPerson.Id !=null) p.Id==OPerson.Id}
                     AND {(if OPerson.Name !=null) p.Name.Contains(OPerson.Name)}
                     AND {(if condition) where-contion}
                     select p).ToList();
Run Code Online (Sandbox Code Playgroud)

我知道我可以用这种方式做多个查询

list=PersonDao.queryBuilder().where().eq("name",OPerson.name).and().eq("sex",OPerson.sex").query();
Run Code Online (Sandbox Code Playgroud)

但我还要检查值是否存在

sqlite android query-builder ormlite

4
推荐指数
1
解决办法
3654
查看次数

标签 统计

android ×2

ormlite ×2

query-builder ×1

sqlite ×1