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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:45:15+00:00 2026-06-13T06:45:15+00:00

I tried everything, this Using Application context everywhere? and few things more and nothing

  • 0

I tried everything, this
Using Application context everywhere?
and few things more and nothing works.

I need the application context in my DatabaseException class which extends Exception.
I need it because I want to check some sharedpreferences when the exceptions are launched.
The code basically is this:

public class DatabaseException extends Exception {

private static final long serialVersionUID = 1L;

DatabaseException(){
    super();
}

DatabaseException(String s){
    super(s);
}

public DatabaseException (String s, Throwable t){
    super (s,t);
    kindOfException(t.getCause(), s);
}

DatabaseException (Throwable t){
    super (t);
    kindOfException(t.getCause(), null);
}

…

private void createLog() {
    Log.d("Database Exception","On Create Log");
    String listLogs;
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(DatabaseException.class.context);

of course this doesn’t work. So… please, somebody can help me?

  • 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-13T06:45:16+00:00Added an answer on June 13, 2026 at 6:45 am

    It is Simply.. you can not. But when the Execption is raised you can perform

    private void createLog() {
        this.getContext();
        Log.d("Database Exception","On Create Log");
        String listLogs;
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(DatabaseException..
    }
    

    the operation you need in the catch clause.

    You could pass it as paramter but, please, avoid it.

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

Sidebar

Related Questions

I've searched for help and tried everything on this thread , but still can't
I tried everything to get this code working, and I hope someone will save
I tried everything to debug this one but I can't get to the bottom
This might get a little confusing as I have tried everything to make this
Cant get this script to work with my menu really have tried everything any
I've tried everything and it still fails! What's wrong with this code?!?! I wanted
I have gone through many posts on SO regarding this issue: Tried everything in
This page should display a Google ad. I Tried everything but it's not working.
Don't dismiss this as a newbie question! It's not, I'm not, I've tried everything,
im really desperate right now, ive tried everything. Everytime i run my app this

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.