Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ViewFavsActivity extends Activity {
- private static final String DB_NAME = "db.sqlite3";
- private static final String COLUMN_ID = "_id";
- private static final String COLUMN_DESC = "description";
- private static final String COLUMN_STAR = "star";
- private static final String TABLE_NAME = "Content";
- private SQLiteDatabase database;
- Bundle bundle;
- Cursor cursor, setTitle;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_view);
- ExternalDbOpenHelper dbOpenHelper = new ExternalDbOpenHelper(this,
- DB_NAME);
- database = dbOpenHelper.openDataBase();
- refreshCursor();
- bundle = getIntent().getExtras();
- TextView titleText = (TextView) findViewById(R.id.titleText);
- setTitle = database.query(TABLE_NAME, new String[] { COLUMN_DESC },
- null, null, null, null, null);
- int entryID = Integer.parseInt(bundle.getString("elementId"));
- setTitle.moveToPosition(entryID);
- titleText.setText(setTitle.getString(setTitle
- .getColumnIndex(COLUMN_DESC)));
- }
- private void refreshCursor() {
- stopManagingCursor(cursor);
- Intent intent = getIntent();
- cursor = database.query(TABLE_NAME, new String[] { COLUMN_ID, COLUMN_STAR, COLUMN_DESC },
- "_id = ? AND star = ?",
- new String[] { intent.getStringExtra("elementId"), "yes" },
- null, null, null);
- }
- protected void onDestroy() {
- super.onDestroy();
- database.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement