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

The Archive Base Latest Questions

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

Here, TabView is the class which adds this particular fragment. Search is the MainActivity

  • 0

Here, TabView is the class which adds this particular fragment.
Search is the MainActivity which gets the file name from the user.
There are some text files in the assets folder. When the user enters the name , for eg, hello,
It’s concatenated to hello.txt and stored as variable in Search activity. I get this value using the return func.
So, here comes the main problem. When i try to get data from hello.txt,
The app closes abruptly when it comes to this part.. I’ve searched everywhere!Found Nothing!Please help..

    public class fg1 extends Fragment {

        LinearLayout layout;
        private String file;
        private Search obj;
        private Context mX;
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            if (container == null) {
                return null;
            }


        layout = (LinearLayout)inflater.inflate(R.layout.fg_code, container, false);
        TextView snippet = (TextView)layout.findViewById(R.id.codeView);

        mX = TabView.getContext();
        AssetManager assetManager = mX.getAssets();
        file = obj.getFileName();
                InputStream input;
            try {
                 input = assetManager.open(file);

                 int size = input.available();
                 byte[] buffer = new byte[size];
                 input.read(buffer);
                 input.close();
                 // byte buffer into a string
                 String text = new String(buffer);
                 snippet.setText(text);

         } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
         }  
        return layout;
    }
}
  • 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-17T06:13:27+00:00Added an answer on June 17, 2026 at 6:13 am

    Found the answer myself. For any future references,
    Instead of getting data from activity, pass the data to the fragment (fragment’s constructor is advisable) from the parent activity that hosts the particular fragment and use it.

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

Sidebar

Related Questions

I am getting twitter time line data from a custom NSObject class and this
Here's the view: @if (stream.StreamSourceId == 1) { <img class=source src=@Url.Content(~/Public/assets/images/own3dlogo.png) alt= /> }
Here is the code in a function I'm trying to revise. This example works
Here is the code: create table `team`.`User`( `UserID` bigint NOT NULL AUTO_INCREMENT , `Username`
Here is the script I'm using, copied directly from Google: <script type=text/javascript> var _gaq
I have a tabView in android which is created as follows : Intent intentAndroid
Here a snippet of my JSF: <p:tabView id=tabView var=tab value=#{data.tabs} widgetVar=tabViewWidget activeIndex=#{data.newActiveTabIndex}> <p:ajax event=tabClose
Here's the scenario: Window creates a tab bar controller and adds multiple tab bar
In my app initially I created one class abc.java which extends Activity and do
Here is what I am trying to achieve in PHP: I have this string:

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.