android - searchable activity -
here utilize searchable activity , connect database. code done without error forcefulness close error. here code
private void filllist(string query) { // if used fts3 (http://j.mp/aqsyqn), utilize match instead of // // we're not here show advanced sqlite usage dbopenhelper dbopenhelper = new dbopenhelper(getapplicationcontext()); sqlitedatabase db = dbopenhelper.getreadabledatabase(); cursor cr = db.query(dbopenhelper.table_name, null, null,null, null, null, null); string [] = {dbopenhelper.key_position,dbopenhelper.key_file}; int [] = {r.id.textview1,r.id.textview2}; listview lv = (listview) findviewbyid(r.id.lv); listadapter adapter = new simplecursoradapter(getapplicationcontext(), r.layout.simple_list_item_1, cr, from, to); lv.setadapter(adapter); }
and here database dbopenhelper.java
public class dbopenhelper extends sqliteopenhelper { public static final int database_version = 2; public static final string database_name = "player"; public static final string key_position = "position"; public static final string key_file = "file"; public static final string table_name = "tracklist"; public static final string table_create = "create table "+table_name+" ("+key_position+" text, "+key_file+" text);"; dbopenhelper(context context) { super(context, database_name, null, database_version); } @override public void oncreate(sqlitedatabase db) { db.execsql(table_create); } @override public void onupgrade(sqlitedatabase db, int arg1, int arg2) { db.execsql("drop table if exists " + table_name); oncreate(db); }
pls help me. thanx
android
No comments:
Post a Comment