Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8923979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:16:38+00:00 2026-06-15T07:16:38+00:00

I am trying to compare a string from EditText fields to strings in shared

  • 0

I am trying to compare a string from EditText fields to strings in shared preferences. If the strings match a new activity starts. The string in Sharedpreferenced is encoded with Base64. I am trying to compare the edit text string to the sharedpreferences string after it has been decoded but am unable to get the coding correct. how can I code this properly. examples are appreciated. my comparator is on line 77 and 78

 44. public void onClick(View arg0) {
 45.    
 46.   sp=this.getSharedPreferences("AccessApp", MODE_WORLD_READABLE);
 47.  
 48.   
 49.   
 50.   
 51.   byte[] key = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 };
 52.   
 53.   
 54.   try {
 55.    user = sp.getString("USERNAME_KEY", null);
 56.        String decryptedUser = decrypt(user, key);  
 57.        
 58.         
 59.   }
 60.  catch (Exception e) {
 61.   // TODO Auto-generated catch block
 62.   e.printStackTrace();
 63.  }   
 64.  try {
 65.       pass = sp.getString("PASSWORD_KEY", null);
 66.       String decryptedPass = decrypt(pass, key);  
 67.       
 68.        
 69.
 70. } catch (Exception e) {
 71.   // TODO Auto-generated catch block
 72.   e.printStackTrace();
 73. }
 74.  
 75.  if(lBttn.equals(arg0)){
 76.    
 77.     if((uname.getText().toString().equals(decryptedUser))  && 
 78.       (pword.getText().toString().equals(decryptedPass)))
 79.      
 80.           {
 81.         Toast.makeText(this, "You are Logged In", 20000).show();
 82.                
 83.              Intent intent;
 84.               intent=new Intent(this,details.class);
 85.               startActivity(intent);
 86.             flag=1;
 87.           }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:16:44+00:00Added an answer on June 15, 2026 at 7:16 am

    There are 2 copies of decryptedUser and decryptedPass each. One pair inside the try blocks and another pair as members. They are always empty at line 77 because you assign the decrypted values to different variables (lines 56 and 66) that you never use. Move the whole code into a single try block.

    public void onClick(View arg0) {
        ...
        ...
        String decryptedUser;
        String decryptedPass;
        try {
            user = sp.getString("USERNAME_KEY", null);
            decryptedUser = decrypt(user, key);  
            pass = sp.getString("PASSWORD_KEY", null);
            decryptedPass = decrypt(pass, key);
            /* Your if statements follow from here */
            ...
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }   
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to compare two strings I get from a password form in
I'm trying to compare two strings One string is a normal string that I
I am trying to compare a string from getline(file,line) with a std::string s=mmee :
I'm trying to compare two strings in C# as I pull them from Excel
I'm trying to compare a string field from a LINQ query on a database
I am trying to compare a key from a dictionary and a string. if
I've been trying to compare my computername to some pre-set string. From reading around
I'm trying to compare a string stored in a structure. I'm using scanf to
I am trying to compare two text files and output the first string in
I am trying to compare two strings in a simple shell script. I was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.