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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:04:33+00:00 2026-06-06T19:04:33+00:00

Code first: AssetManager mgr = DeviceListActivity.this.getApplicationContext().getAssets(); try { Log.e(Glenn:, address); FileOutputStream fout = mgr.openFd(device/device_address.txt).createOutputStream();

  • 0

Code first:

AssetManager mgr = DeviceListActivity.this.getApplicationContext().getAssets();

try {
    Log.e("Glenn:", address);
    FileOutputStream fout = mgr.openFd("device/device_address.txt").createOutputStream();
    PrintWriter _fout = new PrintWriter(fout);
    _fout.println(address);
    Log.e("Glenn", address);

    _fout.close();
    fout.close();

    InputStream fin =  mgr.open("device/device_address.txt");
    BufferedReader br = new BufferedReader(new InputStreamReader(fin));
    address = br.readLine(); 

    try {
        Log.e("Glenn:", address);
    } catch (NullPointerException e) {
        e.printStackTrace();
    }
} catch (IOException e) {
    e.printStackTrace();
    Log.e("Glenn", "error with OutputStream");
}

The value of address printed by the first two Log.e() calls is the right value, which actually is a device MAC address. However, when I was trying to test the value of address read from the file, which had just been written, NullPointerException has been caught within the Log.e() call. This means the value read from the file is NULL. Can anyone point out what’s wrong with the code?

  • 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-06T19:04:34+00:00Added an answer on June 6, 2026 at 7:04 pm

    You cannot write in your app’s asset file. You have only read but not write permissions. AssetManager only provides methods to read the files from your app’s asset folder.

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

Sidebar

Related Questions

Code first: '''this is main structure of my program''' from twisted.web import http from
I know that Code-First uses conventions for model binding, and that this is the
In my code-first setup, I prefer not to allow the consumer (in this case
I am using EF Code First with DontDropDbJustCreateTablesIfModelChanged . I am using this because
Is this possible with Code First? I could do this if I only used
I have a code-first EF model based on 4.3.1. In this model there is
I wrote code first without using functions to prototype, and of course, it worked
I'm using the Code First approach and have the following Model: public class Person
I'm using Code First with EF 5. Currently I have SPs that return just
When using Entity Framework Code First 4.3.1 it is possible to create relationships with

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.