I followed the instructions in implementing SQLiteAssetHelper here
I have a database that contains one table, tbl_items
Tried looking in the Android Device Monitor if it created my table, but it's not listed there. (or it's not supposed to be listed there? package name > file explorer > data > data > package name > databases)
Inside my class I have this code:
public class DBItems extends SQLiteAssetHelper{
public DBItems(Context context) {
super(context, "Items.db", null, 1);
}
public Cursor ItemInfo(String itemID){
SQLiteDatabase database = this.getReadableDatabase();
Cursor info = database.rawQuery("SELECT * FROM tbl_items WHERE itemID = '" + itemID + "'", null);
return info;
}
}
And im trying to access it in my fragment:
DBItems dbItems = new DBItems(getActivity());
@Override
public void onClick(View v) {
Cursor info = dbItems.ItemInfo(String.valueOf(v.getTag())); //I've set a tag in my button
while(info.moveToNext()){
//display info
}
Everytime I clicked the button, it just exits the app. Did I miss something? or what am I doing wrong here?