LizG LizG - 4 months ago 11x
Android Question

Receive .txt file from and place in textview

I am trying to get the text from a .txt file in parse and convert it to String and place the text in a textview. I tried doing what someone suggested while researching by doing it the same way as an image (

As you can see from the images, i have a column "recipe" that consists of txt files. The logcat shows that the file is retrieved from parse and when i click on it, it shows me my file. I can't seem to get the text onto my textview. Any help would be greatly appreciated.


protected void onListItemClick(ListView l, View v, int position, long
id) {
super.onListItemClick(l, v, position, id);

ParseObject po = mAppetizers.get(position);

ParseFile recipes = po.getParseFile("recipe");

// TODO: Get fields from Parse
String title = po.getString(AppetizerRecipe.ARG_NAME);
String time = po.getString(AppetizerRecipe.ARG_TIME);
String ID = po.getObjectId().toString();
Log.d("Appetizer", "object: " + ID);

Intent intent = new Intent(Appetizer.this, AppetizerRecipe.class);

// TODO: Put extras
intent.putExtra(AppetizerRecipe.ARG_NAME, title);
intent.putExtra(AppetizerRecipe.ARG_TIME, time);
intent.putExtra("ID", ID);
Log.d("Appetizer", "object: " + ID);

startActivity(intent); // TODO: In other activity, get these extras

ParseQuery<ParseObject> gettext = new ParseQuery<>("Appetizers");
gettext.whereEqualTo("ID", ID);
gettext.getInBackground(ID, new GetCallback<ParseObject>() {
public void done(ParseObject textobject, ParseException e) {
if (e == null) {
// success
final ParseFile textObject = (ParseFile) textobject.get("recipe");
textObject.getDataInBackground(new GetDataCallback() {
public void done(byte[] data, ParseException e) {
if (e == null) {
// use data for something

} else {


} else {
// fail
Log.d("test", "Error Message..." + e.getMessage());
}); logcat text file from


To get a String from a byte[]:

//your byte[] being data
String str = new String(data);

and then set the String on your TexView like: