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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:53:46+00:00 2026-06-08T17:53:46+00:00

I have a application using a sqlite DB which is put into an ArrayList.

  • 0

I have a application using a sqlite DB which is put into an ArrayList. I am trying to get the entries to show in alphabetical or from what I understand “natural ordering”. I have implemented comparable and have added my collections.sort statement but the array list remains in non alphabetical or natural order. please advise

public class LoginList extends Activity implements OnClickListener, OnItemClickListener {

private ListView loginList;
private Button webLogin;
private ListAdapter loginListAdapter;
private ArrayList<LoginDetails> loginArrayList;

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.login_listview);

    loginList = (ListView)
    findViewById(R.id.loginlist);
    loginList.setOnItemClickListener(this);

    webLogin = (Button)
    findViewById(R.id.button3);
    webLogin.setOnClickListener(this);

    loginArrayList = new ArrayList<xxxxxxxx>();
    loginListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList());
    loginList.setAdapter(LAdapter);
    Collections.sort(AList );

    }

@Override
public void onClick (View v) {
    Intent webLoginIntent = new Intent (this, LoginPlusActivity.class);
    startActivity(webLoginIntent);

}

public List<String> populateList (){

    List<String> webNameList = new ArrayList<String>();


    dataStore openHelperClass = new dataStore (this);

    SQLiteDatabase sqliteDatabase = openHelperClass.getReadableDatabase("xxxxxxxx");

    Cursor cursor = sqliteDatabase.query(dataStore.TABLE_NAME_INFOTABLE, null, null, null, null, null, null);

    startManagingCursor(cursor);

    while (cursor.moveToNext()){

    String sName = cursor.getString(cursor.getColumnIndex(dataStore.COLUMN_NAME_SITE));
    String wUrl = cursor.getString(cursor.getColumnIndex(dataStore.COLUMN_NAME_ADDRESS));
    String uName = cursor.getString(cursor.getColumnIndex(dataStore.COLUMN_NAME_USERNAME));
    String pWord = cursor.getString(cursor.getColumnIndex(dataStore.COLUMN_NAME_PASSWORD));

    LoginDetails lpDetails = new LoginDetails();

        lpDetails.setsName(sName);
        lpDetails.setwUrl(wUrl);
        lpDetails.setuName(uName);
        lpDetails.setpWord(pWord);

        loginArrayList.add(lpDetails);
        webNameList.add(sName); 
}
sqliteDatabase.close();
return webNameList;
}

@Override
protected void onResume() {
    super.onResume();
loginListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList());
loginList.setAdapter(loginListAdapter);
    }

@Override
public void onItemClick(AdapterView<?> arg0 , View arg1, int arg2, long arg3) {
    Toast.makeText(getApplicationContext(), "Selected ID :" + arg2, Toast.LENGTH_SHORT).show();

    Intent updateDeleteLoginInfo = new Intent (this, UpdateDeleteLoginList.class);

    LoginDetails clickedObject = loginArrayList.get(arg2);

        Bundle loginBundle = new Bundle();
    loginBundle.putString("clickedWebSite",clickedObject.getsName());
    loginBundle.putString("clickedWebAddress",clickedObject.getwUrl());
    loginBundle.putString("clickedUserName",clickedObject.getuName());
    loginBundle.putString("clickedPassWord",clickedObject.getpWord());  

    updateDeleteLoginInfo.putExtras(loginBundle);   
    startActivity(updateDeleteLoginInfo);
}
    }

SQLite:

 String sqlDataStore = "create table if not exists " + TABLE_NAME_XXXXXXXXX + " ("+ BaseColumns._ID + "integer primary key autoincrement "

                    + COLUMN_NAME_XXXX + " text not null,"
                    + COLUMN_NAME_XXXXXXX + " text not null,"
                    + COLUMN_NAME_XXXXXXXX + " text not null,"
                    + COLUMN_NAME_XXXXXXXX + " text not null);"
  • 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-08T17:53:47+00:00Added an answer on June 8, 2026 at 5:53 pm

    Replace this line:

      Cursor cursor = sqliteDatabase.query(dataStore.TABLE_NAME_INFOTABLE, null, null, null, null, null, null);
    

    With this:

      Cursor cursor = sqliteDatabase.query(dataStore.TABLE_NAME_INFOTABLE, null, null, null, null, dataStore.COLUMN_NAME_SITE, null);
    

    To order your results by the COLUMN_NAME_SITE.

    This way, your cursor will be preordered when you have done the query and you don’t need a comparable interface.

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

Sidebar

Related Questions

I have been working with iPhone application in which i am using sqlite database.
I have an application in XCode using the sqlite/coredata database and that has already
I have a WPF Application using Fluent NHibernate 1.0 RTM and System.Data.SQLite 1.0.65 that
I am using the Sqlite Database in my Application, I have already upload my
I have created a file named MyFile.db using SQLite3 from my C#.net application. This
I have an application using FeedbackPanel to show the user the results of posting
I have an android application using an SQLite database. I open the database when
I have created the application which is based on Sqlite database. So in my
We have an application which uses SQLite as an embedded RDBMS. Initially the application
I started developing my rails application using sqlite. I have reached a point where

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.