jeudi 3 mars 2016

How to update a column value with another updated column value in separate activity in SQLITE database android

Currently i am developing a sqlite application in android . i have a table and i have created two activities admin activity and user activity. admin activity can cantroll the all functionalities where user can only do some limited actions. i have column name recharge amount where a admin can update the value time to time for distributing recharge amount to the users and my goal is the user will also see this update value after login his account. obviously he will only see his allocated recharge amount which depends on admin . i have filtered specific user with their email id in my query for cursor and my query was something like this -

public Cursor getSelectedProfile(String useridinput) 
    {
        // TODO Auto-generated method stub
        SQLiteDatabase db=getReadableDatabase();
        Cursor selecteditemcursor=db.rawQuery("SELECT _id,profile_name,rechargeamount FROM recharge where user_email=?", new String[]{useridinput});

        return selecteditemcursor;
    }

Main class

public void displayStatus()
    {
     String useridinput=userprofileid.getText().toString();



        Cursor cursor=dbhelper.getSelectedProfile(useridinput);
        String[]from=new String[]{dbhelper.COLUMN_ID,dbhelper.COLUMN_USER_NAME,dbhelper.COLUMN_RECHARGEVALUE};
        int[]to=new int[]{R.id.idvlaue,R.id.namevalue,R.id.rechargevalue};
        simpleadapter=new SimpleCursorAdapter(this,R.layout.itemlayout,cursor,from,to,0);
        statuslist.setAdapter(simpleadapter);




    // Cursor cursor=dbhelper.getProfileItems(int userid)
    }

in main activity i have only seen the user id and username has changed but the recharge amount was unchanged . i have tested it from admin view and change the recharge value from there but value is unchanged . so how can i approach this problem. i am new in android programming and any help will be appreciated thanks

Aucun commentaire:

Enregistrer un commentaire