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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:04:27+00:00 2026-06-09T07:04:27+00:00

It was working fine, I dont know what changes I made, what I had

  • 0

It was working fine, I dont know what changes I made, what I had done wrong, it is not working anymore

everything is ok, table is creating, values are inserting, even displaying table data in log, call is going to custom cursor adapter, but all i came to know through debugging is

newView and Bind view methods of my custom cursor adapter not calling

  • During debugging I saw values are there in cursor when in custom cursorAdapter constructor but newView and bindView is not calling
    here is mmy code:

    public class DbHelper extends SQLiteOpenHelper{
    
    private static final String dbName = "(AnnoyingAlarmDatabase).db";
    private static final int version = 1;
    public static final String keyId = "_id";
    public static final String hour = "hour";
    public static final String minute = "min";
    public static final String strength = "strength";
    public static final String vibrate = "vibrate";
    public static final String snooze = "snooze";
    public static final String method = "method";
    public static final String label = "label";
    public static final String days = "days";
    
    private static final String createTable = "create table alarms (" + keyId + " integer primary key, " + label + " text, " + hour + " integer, " + minute + " integer, " + strength + " text, " + vibrate + " text, " + snooze + " integer, " + method + " text " +")";
    
    
    public DbHelper(Context context) {
    // TODO Auto-generated constructor stub
    super(context, dbName, null, version);
    Log.d("mydb", "constructor");
    }
    
      @Override
    
          public void onCreate(SQLiteDatabase db) {
    try{
    
    Log.d("mydb", "oNCreate()");
    db.execSQL(createTable);
    }
    
    catch( SQLException e)
    {
        e.printStackTrace();
    }
     }
    
     @Override
            public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    db.execSQL("DROP TABLE IF EXISTS alarms" );
    
    
        onCreate(db);
    
     }
    
          public void addAlarm( String getLabel, int getHour, int getMin, String getStrength, String getVibrate, int getSnooze, String getMethod, String getDays )
      {
    
               Log.d("mydb", "addAlarm");
       SQLiteDatabase db = this.getWritableDatabase();
       ContentValues values = new ContentValues();
    
       values.put( label , getLabel);
       values.put( hour , getHour);
    values.put( minute , getMin);
    values.put( strength , getStrength);
    values.put( vibrate , getVibrate);
    values.put( snooze , getSnooze);
    values.put( method , getMethod);
    
    db.insert("alarms", null, values);
    
    db.close();
    
    
       }
    
          public Cursor getAlarm( )
      {
    
              Log.d("mydb", "getAlarm");
    
    
    SQLiteDatabase db = this.getReadableDatabase();
    Cursor cursor = db.rawQuery("select * from alarms", null);
    
    try{
        while( cursor.moveToNext())
        {
            Log.d("db id", cursor.getString(0));
            Log.d("db label",cursor.getString(1));
            Log.d("db hour",cursor.getString(2));
            Log.d("db minute",cursor.getString(3));
            Log.d("db strength",cursor.getString(4));
            Log.d("db vibrate",cursor.getString(5));
            Log.d("db snooze",cursor.getString(6));
            Log.d("db method",cursor.getString(7));
            //Log.d("db days",cursor.getString(8));
        }
    
    }
    
    catch( SQLException e )
    {
        e.printStackTrace();
    }
    
    finally{
    //  cursor.close();
        db.close();
    }
    
    cursor.moveToFirst();
    
    //db.close();
      return cursor;
        }
    

activity:

     public class ViewAlarms extends ListActivity {

Cursor cursor;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    DbHelper db = new DbHelper(this);

    cursor = db.getAlarm();
String [] from = {DbHelper.label};
    int [] to = {R.id.textViewLabel};


//  SimpleCursorAdapter adapter =  new SimpleCursorAdapter(this, R.layout.row_view, cursor, from, to);
//  setListAdapter(adapter);


    CustomCursorAdapter adapter = new CustomCursorAdapter(this, cursor);
    setListAdapter(adapter);
    cursor.close();

}

custom cursor adapter

public class CustomCursorAdapter extends CursorAdapter {

    private LayoutInflater inflator;
    private int hourIndex;
    private int minIndex;
    private int labelIndex;


    public CustomCursorAdapter(Context context, Cursor c) {
        super(context, c);
        inflator = LayoutInflater.from(context);
        hourIndex = c.getColumnIndex(DbHelper.hour);
        minIndex = c.getColumnIndex(DbHelper.minute);
        labelIndex = c.getColumnIndex(DbHelper.label);
        Log.d("customAdapter", "constructor");
        //Log.d("adapter curconst",c.getString(minIndex));
        }

    @Override
    public void bindView(View view, Context context, Cursor cursor) {

        TextView label = (TextView)view.findViewById(R.id.textViewLabel);
        TextView time = (TextView)view.findViewById(R.id.textViewTIme);
        Log.d("adapter cursor","chala?");

    //time
        int hour = Integer.parseInt(cursor.getString(hourIndex));
        int min = Integer.parseInt(cursor.getString(minIndex));
        String minStr;

        if ( min < 10 )
        {
            minStr = "0" + min;
        }
        else
        {
            minStr = "" + min;
        }
        if ( hour < 12 )
        {
            if ( hour == 0 )
                hour = 12;
            time.setText(hour + ":" + minStr + " Am");
        }

        if ( hour > 12 )
        {
            if ( hour == 0 )
                hour = 12;
            time.setText(hour % 12 + ":" + minStr + " Pm");
        }

        //label
        label.setText(cursor.getString(labelIndex));
    }

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup arg2) {
        Log.d("newView","chala");
        return inflator.inflate(R.layout.row_view, arg2, false);
    }

}

Even i tried simple cursor adapter,it still does not show anything.

  • 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-09T07:04:29+00:00Added an answer on June 9, 2026 at 7:04 am

    The constructor you are using has been deprecated . You should be using a Loader.
    Here is some more documentation

    To try to answer your question. Have you tried removed the cursor.close() line right after your call to setAdapter(). You may be closing your cursor while your adapter still needs it. This would also be fixed by using a Loader because that handels lifecycle events better for you.

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

Sidebar

Related Questions

in netbeans 7 and jdk 7 and everything is working fine without any changes
I don’t know why but my Magento installation which was working fine yesterday, is
I don't know what happened to my Firefox (other browsers working fine). I tried
This is working fine in core php, but not in magento. $party_payment = new
My form is working fine with the validations being done by PHP. I have
Everything is working fine until I call the saveFile method (shown below) to write
My code is working fine without any errors when running in Netbeans. If I
My app was working fine on my server. I moved it to another server,
This is working fine in Firefox and IE, but I can't get this to
I have a project working fine under MSVS 2010 SP1. I'm trying to convert

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.