Read from database Android, query -
i'm trying read database i've created , in logcat appears: "style contains key bad entry: 0x01010479" , "(1) no such table: feedreader". have been testing lot of hours , don't know problem
context contexto = this; database dbhelper=new database(contexto); sqlitedatabase db=dbhelper.getwritabledatabase(); string[] columns={"columnname","columnimage","columnsound"}; cursor c=db.query("feedreader", null, null, null, null, null, null); if (c.movetofirst()) { //recorremos el cursor hasta que no haya más registros for(c.movetofirst(); !c.isafterlast(); c.movetonext()){ namec[c.getcount()]= c.getstring(1); //imagec[c.getcount()]= c.getstring(2); //soundc[c.getcount()]= c.getstring(3); } } c.close(); db.close(); }catch(sqliteexception e) { system.out.println(e.getmessage());}
here how create database
public class database extends sqliteopenhelper{ public static final int database_version = 1; public static final string namedatabase = "feedreader"; public string createentires="create table dbsound(" + "id integer primary key autoincrement," + "columnname text,columnimage text,columnsound text)"; public string deleteentires = "drop table if exists dbsound"; public database(context context) { super(context, namedatabase, null, database_version); // todo auto-generated constructor stub } @override public void oncreate(sqlitedatabase db) { db.execsql(createentires); } @override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { db.execsql(deleteentires); oncreate(db); } public void ondowngrade(sqlitedatabase db, int oldversion, int newversion) { onupgrade(db, oldversion, newversion); }
actually table name dbsound
. do
cursor c=db.query("dbsound", null, null, null, null, null, null);
feedreader
database name.
Comments
Post a Comment