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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:20:14+00:00 2026-06-06T07:20:14+00:00

I try to parse a file in my DatabaseHandler class but Eclipse say: The

  • 0

I try to parse a file in my DatabaseHandler class but Eclipse say:

The method getAssets() is undefined for the type DatabaseHandler

This is the code:

 public class DatabaseHandler extends SQLiteOpenHelper {

    private static final int DATABASE_VERSION = 15;

    public DatabaseHandler(Context context) {
        super(context, "rettinfo", null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        Log.d("Create: ", "Creating antidotlist");
        String CREATE_ANTIDOT_TABLE = "CREATE TABLE antidots (id INTEGER PRIMARY KEY antidot TEXT, dos TEXT)";
        Log.d("Create: ", CREATE_ANTIDOT_TABLE);
        db.execSQL(CREATE_ANTIDOT_TABLE);

        InputStream antidots = getAssets().open("antidot/antidots");
        InputStreamReader input = new InputStreamReader(antidots);
        BufferedReader buffreader = new BufferedReader(input,2*1024);
        String line;
        while ((line = buffreader.readLine()) != null) {
            String[] point_t = line.split(",");
        }
        antidots.close();
    }

}

Update for Tim

This is how eclipse dont make any errors

int i = 0;
InputStream antidots;
    try {
        antidots = mCtx.getAssets().open("antidot/antidots");
        InputStreamReader input = new InputStreamReader(antidots);
        BufferedReader buffreader = new BufferedReader(input,2*1024);
        String line;
        while ((line = buffreader.readLine()) != null) {
            i++;
            ContentValues values = new ContentValues();
            String[] antidot = line.split("#");
            int id = Integer.parseInt(antidot[0]);
            values.put("id", id);
            values.put("antidot", antidot[1]);
            values.put("dos", antidot[2]);  
            db.insert("antidots", null, values);                     
        }
        antidots.close();           
    } catch (IOException e) {
        e.printStackTrace();
    }
  • 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-06T07:20:15+00:00Added an answer on June 6, 2026 at 7:20 am

    Store a reference to the Context that you get from the constructor then call getAssets() on that reference.

    public class DatabaseHandler extends SQLiteOpenHelper {
    
        private static final int DATABASE_VERSION = 15;
        private Context mCtx; //<-- declare a Context reference
        public DatabaseHandler(Context context) {
            super(context, "rettinfo", null, DATABASE_VERSION);
            mCtx = context; //<-- fill it with the Context you are passed
        }
    
        @Override
        public void onCreate(SQLiteDatabase db) {
            Log.d("Create: ", "Creating antidotlist");
            String CREATE_ANTIDOT_TABLE = "CREATE TABLE antidots (id INTEGER PRIMARY KEY antidot TEXT, dos TEXT)";
            Log.d("Create: ", CREATE_ANTIDOT_TABLE);
            db.execSQL(CREATE_ANTIDOT_TABLE);
    
            InputStream antidots = mCtx.getAssets().open("antidot/antidots"); //<-- call getAssets on your Context object.
            InputStreamReader input = new InputStreamReader(antidots);
            BufferedReader buffreader = new BufferedReader(input,2*1024);
            String line;
            while ((line = buffreader.readLine()) != null) {
                String[] point_t = line.split(",");
            }
            antidots.close();
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm try to parse this xml, but c# keeps throwing an exception saying it
maybe this is a n00b-question. I try to parse an xml-file like that: <?xml
I have a xml file which contains arabic characters.When i try to parse a
try{Integer.parse(Abhishek);} catch(NumberFormatException e){} catch(Exception e){} If for the above piece of code, if NumberFormatException
I have a JSON which I get from web application. I try this parse
i try to parse an rdf file using android.sax and android.utils.Xml methods. My parser
I try to parse an xml file. The text which is in tags is
I have text file. I try to parse it in erlang. Text format: pattern1
struct is necessary when you try to parse some file format like ELF, etc...
I have a piece of code that goes like this File file = null;

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.