I’m using the program found on this programming blog for using pre-populated sqlite table. I am trying to insert any row in the table but it is giving always SQLException:
Problems executing Android query: SELECT * FROM `user` WHERE `username`='Shadow'
This is the method where I’m getting this error:
public User getByUsername(String username) {
try {
QueryBuilder<User, String> qb = userDao.queryBuilder();
qb.where().eq("username", username);
PreparedQuery<User> pq = qb.prepare();
return userDao.queryForFirst(pq);
} catch (SQLException e) {
e.printStackTrace();
return null;
}
}
Looking for help…
Without more information about the specific error you are getting (please add the full exception to your question), we can’t really help you @deepak
I will say that your code looks well formed and appropriate. I like to define the fields that I use in queries like the following:
Then your code can be something like the following. This solves problems with queries and database schemas not matching:
If you post your exception, I’ll edit my answer with more help.