简体   繁体   中英

parse file displays random alphanumeric text in textView Android

I am getting a parse file back from parse.com which is a string message and displaying it in textView.

ParseFile file = message.getParseFile(ParseConstants.KEY_FILE);
        String filePath = file.getDataInBackground().toString(); 

        if (messageType.equals("string")){
            Intent intent = new Intent(getActivity(), StringActivity.class);
            intent.putExtra("file", filePath);

string activity class i try to display file in textView:

 protected TextView mDisplay;
 mDisplay = (TextView)findViewById(R.id.stringDisplay);

 String mess = getIntent().getStringExtra("file");

 byte[] by = mess.getBytes();
 String filePath =new String(by);
 mDisplay.setText(filePath);

whats displayed in the textView is this bolts.Task@12af9f90 random numbers.

how can i get the string to display?

This will get you the content of the file:

String fileContent = "";
try {
    fileContent = new String(file.getData());
} catch (ParseException e) {
    e.printStackTrace();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM