i have written a code for an application that works as an assignment tracker. so i want to know how can i retrieve the data corresponding to a specific assignment name when i click on the button View. this is the code for my Database operations
public class DatabaseOperations extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 2;
public String CREATE_QUERY = " CREATE TABLE "+TableInfo.DATABASE_TABLE +" ("+TableInfo.KEY_TITLE +" TEXT,"+TableInfo.KEY_DUEDATE+" TEXT,"+ TableInfo.KEY_COURSE+" TEXT,"+TableInfo.KEY_NOTES+" TEXT);";
public DatabaseOperations(Context context) {
super(context, TableInfo.DATABASE_NAME, null, DATABASE_VERSION);
Log.d("Database Operations", "Database created");
}
public void onCreate(SQLiteDatabase sdb) {
try{
sdb.execSQL(CREATE_QUERY);
}
catch (SQLException e){
e.printStackTrace();
}
Log.d("Database Operations", "Table created");
}
public void onOpen(SQLiteDatabase sdb)
{
try{
sdb.execSQL(CREATE_QUERY);
}
catch (SQLException e){
e.printStackTrace();
}
}
@Override
public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
}
public void putInfo(DatabaseOperations dop,String assignmentname, String duedate, String course, String Notes)
{
SQLiteDatabase SQ = dop.getWritableDatabase();
ContentValues cv= new ContentValues();
cv.put(TableInfo.KEY_TITLE, assignmentname);
cv.put(TableInfo.KEY_DUEDATE, duedate);
cv.put(TableInfo.KEY_COURSE, course);
cv.put(TableInfo.KEY_NOTES,Notes);
long k = SQ.insert(TableInfo.DATABASE_TABLE, null,cv);
Log.d("Database Operations", "one row inserted");
}
public Cursor getInfo(DatabaseOperations dop,String assignmentname)
{
}
} and this is the java code for another page where i input the name of the assignment corresponding to which i want the data
public class viewassignment extends Activity {
String x;
public void OnCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.viewassignment);
Button button1 = (Button) findViewById(R.id.button1);
final EditText Text1 = (EditText) findViewById(R.id.Text1);
button1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
x = Text1.getText().toString();
}
});
}
}
i am really new to this so please help me out
Aucun commentaire:
Enregistrer un commentaire