I have made this code to open a database(created in SQLite browser) stored in assets folder in my app:
public class DatabasetryActivity extends ListActivity {
/** Called when the activity is first created. */
private ArrayList<String> queryString;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DatabaseHelper myDbHelper = new DatabaseHelper(this);
myDbHelper = new DatabaseHelper(this);
queryString = myDbHelper.getData(new String[] {"Area","disease"}, null, null, null,
"Area"," ASC");
try {
myDbHelper.createDataBase();
} catch (IOException ioe) {
throw new Error("Unable to create database");
}
try {
myDbHelper.openDataBase();
}catch(SQLException sqle){
throw sqle;
}
setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1
queryString));
getListView().setTextFilterEnabled(true);
}
where DatabaseHelper is another class in same package but while running this android project on emulator the following message appears on console tab:
ActivityManager: Warning: Activity not started, its current task has been brought to
the front
and nothing appears on the emulator. please help me out. Thanks
Guys please help me out as this is my first post here..and i am new to android
What you want to use to create your data base is actually an SQLiteOpenHelper. You can find the documentation for it here. You can also find various questions about it on StackOverflow. You can then use a list adapter to add database items to a list. This should simplify your code and make the SDK work for you. You can Google this and there will be many example.
Also a tip for future posts. You can add spaced to the code in your questions/answers so the indentations are correct and make it easier to read. StackOverflow is a great community and will help you learn quickly as a developer. Welcome and get involved!