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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:15:50+00:00 2026-05-21T10:15:50+00:00

I have an application, which does smth… at the begining of main class I

  • 0

I have an application, which does smth… at the begining of main class I do the following:

myCommunicator = new Communicator();
    // LOAD DB
    dbAdapter = new ToDoDBAdapter(this);
    dbAdapter.open();
    // CHECK CHANNEL CHANGES
    try {
      dbHandler = dbAdapter.getAllChannelNames();
      startManagingCursor(dbHandler);
      String md5Channels = "";
      while (dbHandler.moveToNext()) 
      {
          String xy = dbHandler.getString(0);
          md5Channels += xy;
      }
      // 2. Make MD5 string
      md5Channels = myCommunicator.md5(md5Channels); 

      // 3. Compare MD5
      ChannelsArray = myCommunicator.getChannels(md5Channels);
      // 4. Update if needed
      if(ChannelsArray.length() > 0)
      {
          dbAdapter.populateDB(ChannelsArray);
      }

      dbHandler = dbAdapter. getAllToDoItemsCursor();

    } 
    catch (JSONException e) {
            Log.d(" - PopulateChannels - ", "Napaka: " + e.toString());
        }

myCommunicator, dbAdapter, dbHandler, ChannelsArray are defined…

Than I have

public Cursor getChannelCursor()
{
    return dbHandler;
}
public ToDoDBAdapter getDBAdapter()
{
    return dbAdapter;
}
public Communicator getCommunicator()
{
    return myCommunicator;
}
public JSONArray getChannelsArray()
{
    return ChannelsArray;
}

This class have tabhost * will call it Activity1… And when I call from another class * will call it Activity2…(inside tabost) the result is null …

So when I do Activity1.getChannelsArray(); (or any other function) from Activity2 it is always null… Have no idea how to solve it…


Hi, sorry for lack of infos…

I have main activity… called at the beginning (Activity1)… I populate DB there (if any changes) and create DB Cursor… This activity hold TabHost…

The easiest way to explain is to write some code:

Here is Activity1 (main activity)

package com.Avtivity1;
public class activity1 extends Activity
{

  public void onCreate(Bundle savedInstanceState) { 
  ...
     dbAdapter = new ToDoDBAdapter();
  }
  public ToDoDBAdapter getDBAdapter()
  {
    return dbAdapter;
  }
}

And now another one:

package com.Avtivity1;
public class activity1 extends TabActivity implements OnTabChangeListener 
{
  private ToDoDBAdapter dbAdapter;
  @Override
  public void onCreate(Bundle icicle) { 
  ...
     Activity1 Activity1 = new Activity1();
     Activity1.getDBAdapter();
  }
  public ToDoDBAdapter getDBAdapter()
  {
    return dbAdapter;
  }
}

And this part Activity1.getDBAdapter(); always returns 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-05-21T10:15:51+00:00Added an answer on May 21, 2026 at 10:15 am

    In general, don’t persist data in an Activity that needs to be used in other parts of the Application. The life of an Activity cannot be relied on since the system might reclaim it’s resources based on needs such as low memory.

    Instead, store your values in a singleton non-Activity class.

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

Sidebar

Related Questions

I have a C# windows application which does the following: 1) the main form
I have made a console application which does something. It looks like: class C
I have the following code in my application which does two things: Parse the
I have this web application which does the following as standard to all websites
I have an ASP.NET web application which does the following: Reads an Excel file.
I have an existing application which does all of its logging against log4j. We
I have inherited couple of .Net (C#) application which does not have any tracing
I have this scala application which is very simple . All that it does
I have an application which logs in into a webservice. I start a new
I have Winform application,which does some operation in loops (file access, copy file, ....).

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.