Reputation: 741
I created database and table in sqlite database after that i can take thedatabaseoutside using file explore. And then i inserted some values into the table again i paste the database in same location in file explore .if i am run in emulator means it takes data from sqlite and populate listview in android mobile. after that the same app i put in mobile means it cannot take sqlite database.i think the sqlite database cannot dumped to the mobile while installing my app..please tell me the solution how to solve?
This my database class
public Cursor queueAll() {
String[] columns = new String[] { KEY_ID, KEY_CONTENT };
Cursor cursor = sqLiteDatabase.query(MYDATABASE_TABLE, columns, null,
null, null, null, null);
int id = cursor.getColumnIndex(KEY_CONTENT);
cursor.moveToFirst();
if (cursor != null) {
do {
String keyid = cursor.getString(id);
System.out.println(keyid);
} while (cursor.moveToNext());
}
return cursor;
}
private static class SQLiteHelper extends SQLiteOpenHelper {
public SQLiteHelper(Context context, String name,
CursorFactory factory, int version) {
super(context, name, factory, version);
}
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL(apptable);
db.execSQL(souptable);
db.execSQL(vegtable);
db.execSQL(ricetable);
db.execSQL(desserttable);
db.execSQL(FoodMenutable);
db.execSQL(SCRIPT_CREATE_DATABASE);
db.execSQL(DATABASE_CREATE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub
}
}
public long AddUser(String username, String password) {
ContentValues initialValues = new ContentValues();
initialValues.put(KEY_USERNAME, username);
initialValues.put(KEY_PASSWORD, password);
return sqLiteDatabase.insert(DATABASE_TABLE, null, initialValues);
}
public boolean Login(String username, String password) {
// TODO Auto-generated method stub
Cursor mCursor = sqLiteDatabase.rawQuery("SELECT * FROM "
+ DATABASE_TABLE + " WHERE username=? AND password=?",
new String[] { username, password });
if (mCursor != null) {
if (mCursor.getCount() > 0) {
return true;
}
}
return false;
}
}
please help me
Upvotes: 0
Views: 407
Reputation: 3858
enter manually data in your database using your application because you can't modify or import database of your application from android mobile.
Upvotes: 1