Ivan Kocijan Koc
It doesn't matter if you win by an inch or a mile. Winning's winning.
Ivan Kocijan - ikocijan0@gmail.com
Milan Jovanović -milan.jovanovic24@gmail.com
Intent intent = new Intent(MainActivity.this, ReadFromDbActivity.class); intent.putExtra("key", "value"); startActivity(intent);
getIntent().getExtras().get("key");
DbHelper mDbHelper = new DbHelper(Context);
SQLiteDatabase db = mDbHelper.getWritableDatabase();
ContentValues values = new ContentValues(); values.put(DBExampleContract.DBEntry.COLUMN_USER_NAME,
name.getText().toString()); values.put(DBExampleContract.DBEntry.COLUMN_USER_SURNAME,
surname.getText().toString()); values.put(DBExampleContract.DBEntry.USER_DESCRIPTION,
description.getText().toString());
db.insert(DBExampleContract.DBEntry.TABLE_NAME, null,values);
SQLiteDatabase db = mDbHelper.getReadableDatabase();
//Which columns from the database will be used String[] projection = { DBExampleContract.DBEntry.COLUMN_USER_NAME, DBExampleContract.DBEntry.COLUMN_USER_SURNAME, DBExampleContract.DBEntry.USER_DESCRIPTION }; Cursor cursor = db.query( DBExampleContract.DBEntry.TABLE_NAME, // The table to query projection, // The columns to return null, // The columns for the WHERE clause null, // The values for the WHERE clause
null, // don't group the rows null, // don't filter by row groups null // The sort order );
cursor.moveToFirst();
while (cursor.moveToNext()) {
cursor.getString(cursor.getColumnIndex
(DBExampleContract.DBEntry.COLUMN_USER_NAME));
}
// Where part of query String selection = DBExampleContract.DBEntry.COLUMN_USER_NAME
+ " LIKE ?";
String[] selectionArgs = { String.valueOf(userName.getText().toString())};
db.delete(DBExampleContract.DBEntry.TABLE_NAME, selection,
selectionArgs);
dependencies { compile files('libs/activeandroid.jar')
}
<manifest ...> <application
android:name="ninja.ofca.dolly" ...>
<meta-data android:name="AA_DB_NAME"
android:value="Dolly.db" />
<meta-data android:name="AA_DB_VERSION"
android:value="5" /> </application> </manifest>
public class OfcaApplication extends Applicaton {
@Override public void onCreate() { super.onCreate(); ActiveAndroid.initialize(this); } }
By Ivan Kocijan Koc
Intent extra, Async task, SQLite database, Active Android library
It doesn't matter if you win by an inch or a mile. Winning's winning.