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

  • SEARCH
  • Home
  • 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 7910985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:04:36+00:00 2026-06-03T13:04:36+00:00

If i am using Android 2.2 and call File.list() method in BookGenerator.java , then

  • 0

If i am using Android 2.2 and call File.list() method in BookGenerator.java, then pages and chapters come in exact sequence, but whenever I execute on Android 4.0 it gives me reverse pages list or reverse pages order.

Is there a compatibility issue between 2.2 and 4.0?

  • 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-03T13:04:40+00:00Added an answer on June 3, 2026 at 1:04 pm

    You shouldn’t rely on listFiles() for an ordered list of the pages:

    http://docs.oracle.com/javase/1.4.2/docs/api/java/io/File.html#listFiles()

    “There is no guarantee that the name strings in the resulting array will appear in any specific order;”

    You have to create your own ordering system, based on file name or lastModified or file’s size. You can either use a Comparator < File > or Comparator < String > for sorting the files in a SortedSet, or as mentionned earlier, create an own class for the items to sort that implements Comparable. I would suggest the first solution as it’s a bit stupid to wrap the File or String class into an other one just for this functionality.

    An example with a lot of memory overhead:

    TreeSet<File> pages = new TreeSet<File>(new Comparator<File>(){
       public int compare(File first, File second) {
          return first.getName().compareTo(second.getName());
       }
    });
    
    for (File file : allFiles) {
       pages.add(file());
    }
    
    allFiles = pages.toArray();
    

    If you want a more efficient one, you have to implement your own method for sorting an array in its place.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am using a Android database and it's set up; but when i call
I am using android java to create an application that uses the accelerometer, i
I have built ffmpeg for Android using the code and method described at https://github.com/halfninja/android-ffmpeg-x264
I'm trying to build an Android project using the ndk, but I have run
I need to get call from swf file * to * our android .
Is it possible to call/run a python script file from Java code on the
I am nearing completion of a project I am working on using Android, but
I'm trying to make a RESTful api call from the android emulator (using android
I'm having a problem using Make's wildcard function in my Android.mk build file. My
I want to send a csv file from Android to Python AppEngine. I'm using

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.