How to fetch all column values based on email?

عاقب انصاری

I want to fetch my all the column from table tblReg. It has column Registration, Name, Password, Email and Contact out which Email is checked while registration, it is unique column; value exist only once in table of one Email.

I am having login by matching Email with password and passing value of an email through intent in my home activity as KeyName. Now I want to fetch all detail from SQLlite based on my Email, I am receiving from getExtra through Intent.

Here is my code of Home Activity

public class activity_home extends Activity {
    DatabaseHandler dbh = new DatabaseHandler(this);
String regid,emailid,name,contact,data;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_activity_home);
        TextView lblEmail = (TextView) findViewById(R.id.textView1);
        TextView lblReg = (TextView) findViewById(R.id.textView1);
        TextView lblName = (TextView) findViewById(R.id.textView1);
        dbh.open();
        try {
            data = getIntent().getExtras().getString("keyName");

            Cursor m1 = dbh.getAllData(data);
            if (m1 != null) {
                m1.moveToFirst();
                name = m1.getString(m1.getColumnIndex("Name"));
                regid = m1.getString(m1.getColumnIndex("Registration"));
                contact = m1.getString(m1.getColumnIndex("Contact"));
                emailid = m1.getString(m1.getColumnIndex("Email"));
                m1.close();
            }

            if (!data.equals("")) {

                lblEmail.setText(Html.fromHtml("Email: <b>" + emailid + "</b>"));
                lblReg.setText(Html.fromHtml("Email: <b>" + regid + "</b>"));
                lblName.setText(Html.fromHtml("Email: <b>" + name + "</b>"));
            } else {
                Toast.makeText(getApplicationContext(), "Data Null Aya hai Bhai", Toast.LENGTH_SHORT).show();
            }
        }
        catch (Exception e)
        {
            String ex=e.toString();
            Toast.makeText(getApplicationContext(), ex, Toast.LENGTH_SHORT).show();
        }
            }

I have used a database handler class where I am using a query, I think there is a problem in query, please have a look in that. I am sharing the cursor code, where am I wrong?

 public Cursor getAllData(String parentKey) {

    String[] fields = new String[] {
            KEY_REGID,
            KEY_NAME,
            KEY_PASSWORD,
            KEY_EMAIL,
            KEY_MOBILENO + " as _id "
    };

    Cursor cursor = mDb.query(tblReg,
            fields,
            KEY_EMAIL + " = ?",
            new String[] {
                    "" + parentKey
            },
            null,
            null,
            KEY_NAME);

    cursor.moveToFirst();
    return cursor;
}
عاقب انصاری

I have solved my problem of fetching data from tables based on column values and now I want to share the sloppy mistakes.

TextView lblEmail = (TextView) findViewById(R.id.textView1);
            TextView lblReg = (TextView) findViewById(R.id.textView1);
            TextView lblName = (TextView) findViewById(R.id.textView1);

This code has to be written like as stated below

TextView lblEmail = (TextView) findViewById(R.id.textView1);
                TextView lblReg = (TextView) findViewById(R.id.textView2);
                TextView lblName = (TextView) findViewById(R.id.textView3);

The rest is all working great, any viewer want to learn how to fetch all column values based upon value passed by user can refer the above code.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How to sum the values in a column based on another column or different group?

분류에서Dev

How to repeat all column values for each row in another column

분류에서Dev

Filling in column based on column values

분류에서Dev

mysql query: searching based on all values in column rather than one value in column

분류에서Dev

How to make a new column based on difference of max values by index?

분류에서Dev

How to get duplicate Rows based on few column values?

분류에서Dev

How to fetch the latest Email received in a particular Email id through Jmeter

분류에서Dev

How to get all the values of one column and calculate a total

분류에서Dev

how to get the average of values for one column based on another column value in python (pandas, jupyter)

분류에서Dev

How to filter based on duplicate values in one column and consecutive values in another using PLSQL?

분류에서Dev

How to fetch email id from field and send mail to that

분류에서Dev

How to fetch rows and separate values with comma in a variable?

분류에서Dev

Split/Expand Dataframe based on column values

분류에서Dev

Building a column of values based on a formula in R

분류에서Dev

Building a column of values based on a formula in R

분류에서Dev

selecting a row based on a number of column values in SQLite

분류에서Dev

splitting file based on values in specific column

분류에서Dev

Return the occurance of a value in a column based on other values

분류에서Dev

MySQL query to get values based on same column

분류에서Dev

Mysql split the column values based on the joining table

분류에서Dev

How to get a column of group id values for a pandas DataFrame based on the groups produced by a groupby operation

분류에서Dev

how to list all the email subject in GMail?

분류에서Dev

CFDump of query column does not display all values

분류에서Dev

In standard SQL, how do I select rows such that for each unique value in one column, all of the values in another column are a specified value?

분류에서Dev

Excel - sum values based on a column that match another column in another table

분류에서Dev

Add new column based on boolean values in a different column

분류에서Dev

Multiply column values in SQL, then add all the values - Laravel 4

분류에서Dev

How to Fetch data from SQLite according to Month from a Date Column

분류에서Dev

How to Fetch common column from multiple tables in Database?

Related 관련 기사

  1. 1

    How to sum the values in a column based on another column or different group?

  2. 2

    How to repeat all column values for each row in another column

  3. 3

    Filling in column based on column values

  4. 4

    mysql query: searching based on all values in column rather than one value in column

  5. 5

    How to make a new column based on difference of max values by index?

  6. 6

    How to get duplicate Rows based on few column values?

  7. 7

    How to fetch the latest Email received in a particular Email id through Jmeter

  8. 8

    How to get all the values of one column and calculate a total

  9. 9

    how to get the average of values for one column based on another column value in python (pandas, jupyter)

  10. 10

    How to filter based on duplicate values in one column and consecutive values in another using PLSQL?

  11. 11

    How to fetch email id from field and send mail to that

  12. 12

    How to fetch rows and separate values with comma in a variable?

  13. 13

    Split/Expand Dataframe based on column values

  14. 14

    Building a column of values based on a formula in R

  15. 15

    Building a column of values based on a formula in R

  16. 16

    selecting a row based on a number of column values in SQLite

  17. 17

    splitting file based on values in specific column

  18. 18

    Return the occurance of a value in a column based on other values

  19. 19

    MySQL query to get values based on same column

  20. 20

    Mysql split the column values based on the joining table

  21. 21

    How to get a column of group id values for a pandas DataFrame based on the groups produced by a groupby operation

  22. 22

    how to list all the email subject in GMail?

  23. 23

    CFDump of query column does not display all values

  24. 24

    In standard SQL, how do I select rows such that for each unique value in one column, all of the values in another column are a specified value?

  25. 25

    Excel - sum values based on a column that match another column in another table

  26. 26

    Add new column based on boolean values in a different column

  27. 27

    Multiply column values in SQL, then add all the values - Laravel 4

  28. 28

    How to Fetch data from SQLite according to Month from a Date Column

  29. 29

    How to Fetch common column from multiple tables in Database?

뜨겁다태그

보관