Skip to content

Instantly share code, notes, and snippets.

@marshall
Created September 13, 2010 20:01
Show Gist options
  • Save marshall/577919 to your computer and use it in GitHub Desktop.
Save marshall/577919 to your computer and use it in GitHub Desktop.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView label = (TextView)findViewById(R.id.TextView01);
String dbPath = "/sdcard/test.db";
SQLiteOpenHelper helper = new SQLiteOpenHelper(this, dbPath, null, 1) {
@Override
public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
// TODO Auto-generated method stub
}
@Override
public void onCreate(SQLiteDatabase arg0) {
// TODO Auto-generated method stub
}
};
SQLiteDatabase db = helper.getReadableDatabase();
Cursor c = db.rawQuery("SELECT message FROM test", null);
c.moveToNext();
String message = c.getString(c.getColumnIndex("message"));
c.close();
db.close();
label.setText(message);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment