Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJason Tjahja
8,668 Pointsdidn't find the files in data/data/com.teamtreehouse.mememaker
i can't find the files that already copied to the internal storage, i already search for those files through android device monitor
package com.suedinym.mememakerstarterkit.utils;
import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Environment;
import android.text.TextUtils;
import android.util.Log;
import java.io.File;
import java.io.FileFilter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* Created by Evan Anger on 7/28/14.
*/
public class FileUtilities {
public static void saveAssetImage(Context context, String assetName) {
File fileDirectory = context.getFilesDir();
File fileToWrite = new File(fileDirectory, assetName);
AssetManager assetManager = context.getAssets();
try {
InputStream in = assetManager.open(assetName);
FileOutputStream out = new FileOutputStream(fileToWrite);
copyFile(in, out);
in.close();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private static void copyFile(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[1024];
int read;
while((read = in.read(buffer)) != -1) {
out.write(buffer, 0, read);
}
}
public static Uri saveImageForSharing(Context context, Bitmap bitmap, String assetName) {
File fileToWrite = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), assetName);
try {
FileOutputStream outputStream = new FileOutputStream(fileToWrite);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
outputStream.flush();
outputStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
return Uri.fromFile(fileToWrite);
}
}
public static void saveImage(Context context, Bitmap bitmap, String name) {
File fileDirectory = context.getFilesDir();
File fileToWrite = new File(fileDirectory, name);
try {
FileOutputStream outputStream = new FileOutputStream(fileToWrite);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
outputStream.flush();
outputStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
2 Answers
J A
Full Stack JavaScript Techdegree Student 4,646 PointsBefore you run the app for the first time, you need to enable Tools > Android > Enable ADB Integration. Then fire up the Android Device Monitor. If you don't run the app at least once, they will not be written to the device storage location.
Zaur Kandokhov
12,276 PointsYour package name is 'com.suedinym.mememakerstarterkit.utils' so you need to search files in 'data/data/com.suedinym.mememakerstarterkit'
Jun Kakeno
iOS Development with Swift Techdegree Graduate 24,842 PointsJun Kakeno
iOS Development with Swift Techdegree Graduate 24,842 PointsI've done as advise but the data folder is empty.