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 8971349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:55:58+00:00 2026-06-15T17:55:58+00:00

I am looking for an update function for a custom ROM based tool. I

  • 0

I am looking for an update function for a custom ROM based tool. I used this code http://www.androidsnippets.com/check-for-updates-once-a-day as a base and soon realized that I couldn’t use Dropbox for deployment with that code. So I modified the code to download a version.txt file from dropbox. The file contains a single number (the latest Version Code, in this case 11). I need to read that line and parse the string as an integer to compare with the current versionCode and trigger a download if an update exists.
All the code works, except for parsing the int from the txt file.

Heres my code:

    private Thread checkUpdate = new Thread() {
public void run() {
    try {

        File sdcard = Environment.getExternalStorageDirectory();
        File file = new File(sdcard,"BPversion.txt");
        StringBuilder text = new StringBuilder();
        BufferedReader br = new BufferedReader(new FileReader(file));
        String line;
        while ((line = br.readLine()) != null) {
            text.append(line);

        int curVersion = getPackageManager().getPackageInfo("com.JB15613.BPcolorTool", 0).versionCode;
        System.out.println(line);
        int newVersion = 0;
        System.out.println(line);

        try {
            newVersion = Integer.parseInt(line);
            System.out.println(line);
        } catch(NumberFormatException nfe) {
            System.out.println("Exception " + nfe);
        }

        if (newVersion > curVersion) {
            mHandler.post(showUpdate);
        }    
        }
    } catch (Exception e) {
        Log.d("ANDRO_ASYNC", "Caught exception");

    }
}

And I get this exception:

    Exception java.lang.NumberFormatException: Invalid int: "11"

When I apply breakpoints and run the debugger, it crashes at the parseInt line.

11 looks like a valid int to me!

Any help is greatly appreciated!

  • 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-15T17:56:00+00:00Added an answer on June 15, 2026 at 5:56 pm

    line ends CRLF ,so , need call function trim() in String ..

    int newVersion = Integer.parseInt(line.trim());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to set up a chrome extension similar to http://code.google.com/chrome/extensions/trunk/samples.html#webrequest except that
I'm looking to update twitter using cURL. I've written a bash function, but I'm
I'm looking to update a MySQL database with items from an RSS Feed. When
I am looking to update rows where the date column is NULL by averaging
Looking at all the possibilites of creation / update columns in NHibernate I mostly
Looking for a good tutorial on how to update a mysql database using a
I'm looking forward to have an update on the following topic as it does
I'm looking to find information on how to update my XCode program that has
I am looking for the most efficient way to update a number of rows
Update 3 : Never mind. I kinda got what I was looking for. The

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.