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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:21:02+00:00 2026-05-27T04:21:02+00:00

I package a text file with my Android App (in Assets) which I read

  • 0

I package a text file with my Android App (in Assets) which I read within the App itself.

To avoid this file being compressed, it’s named ‘mytestfile.mp3’ and until recently, that worked just fine.

In one of the recent SDK/ADT changes, it seems something ‘odd’ is happening when reading from Assets and I’m open to ideas as to what it is…

I use code something like this

AssetFileDescriptor descriptor = getAssets().openFd("mytextfile.mp3");
BufferedReader f = new BufferedReader(new FileReader(descriptor.getFileDescriptor()));
String line = f.readLine();
while (line != null) {
    // do stuff
    Log.d("TAG",line);
}

What I’m now seeing from the Log is rather odd – if the file contained something like this

Fred
Barney
Wilma

I’m seeing huge amounts of nonsense like this in the log

��ߴ�!�c�W���6�f����m�>ߩ���'�����6�#6���l0��mp�

followed – eventually by my text content

Fred
Barney
Wilma

followed by another metric tonne of gibberish – some of which looks like this

����������4�u?'����������������������������������������res/drawable-mdpi/icon.pngPK��������|v?,������������'�����������������������������res/layout-land/dialog_color_picker.xmlPK��������|v?1�!�����t2�������������������������������classes.dexPK��������|v?թVڝ����5���������������������������������META-INF/MANIFEST.MFPK��������|v?�v������j���������������������������������META-INF/CERT.SFPK��������|v?W7@�]�������������������������������������META-INF/CERT.RSAPK������������������������

As you can see, that appears to be raw binary content from the APK (and nothing to do with the text file)??

Is this a recent packaging issue or am I missing something? I’m using ADT15 but I’ve not tried the recent upgrade just yet!?

p.s. I’ve upgraded to the latest SDK/ADT and this problem persists – obviously I’d like to escalate it with whoever is at fault (no idea if the problem is Eclipse/ADT/ANT or Android centered) and so I’ll start a bounty for ideas…

  • 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-27T04:21:03+00:00Added an answer on May 27, 2026 at 4:21 am

    This is because AssetFileDescriptor.getFileDescriptor() is for your .apk and not the mytextfile.mp3 file inside the .apk. To work with AssetFileDescriptor you need to take e.g. AssetFileDescriptor.getStartOffset() into account as well, which is the offset to the actual file i.e. mytextfile.mp3 in your case.

    But there’s an easy solution to your problem. Use AssetManager.open(String) instead, which will give you an InputStream to the mytextfile.mp3 file. Like this:

    InputStream inputStream = getAssets().open("mytextfile.mp3");
    BufferedReader f = new BufferedReader(new InputStreamReader(inputStream));
    // ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my .java file in src: package com.wao.texttime; import android.app.Activity; import android.os.Bundle; import
This is my .java file in src: package com.wao.texttime; import java.util.Calendar; import android.app.Activity; import
This is my GPSLoggerservice code: package com.mygps.android; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import
Here I'm reading text file which contains a integer in each line and I'm
I've notice this. Example: create an empty text file called for example ast.py $
Let's say I have a file called test.txt within the package com.test.io within my
Say I have a text file that looks like this: date 1/1/2010 a,b,c a,b,d
I am running the following code to try and read from a text file.
I need to load a text file which is placed in res/raw directory into
I`m trying to read my build version number from a text file, and then

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.