DDMS là gì và ở đâu trong Android?

Anh/Chị cho em hỏi là DDMS là gì và mở ở đâu .Hiện tại em đang dùng Android Studio 2.1.3 và dùng Genymotion .Mong a/c , các bạn giúp em . Em cảm ơn rất nhiều

C

Bạn xem ở đây nè : https://developer.android.com/studio/profile/ddms.html

em cảm ơn anh
em có coi ở đó rồi , làm theo, nhưng kết quả vẫn vô ích

Để tạo file để đọc ghi thì bạn có thể tạo thư mục assets rồi cho file vào đó. Không nhất thiết lúc nào cũng phải theo y như trong tài liệu. Còn DDMS là gì thì google một phát ra ngay ấy mà :v

anh cho em hỏi phải vậy không ạ

Cái ảnh vừa up lên bạn nhấn vào kia xem lỗi gì? Còn cop file vào DDMS thì bạn bật DDMS lên,bên góc phải gần trên cùng có hình 2 cái điện thoại với mũi tên ra vào ấy,để ra vào file

mà cái DDMS của em nó bj sao sao á anh

Đọc như thế không được nhé :v
Google “read txt file from assets android studio” sẽ ra ngay. Chịu khó học tiếng anh cơ bản là có thể dễ dàng tìm mà :v

em cũng hạn hán lời :))

Mình có viết một bài hướng dẫn về SharedPreference. Trong đó hó hướng dẫn mở Android Device Monitor có chứa trình DDMS, bạn có thể thao khảo thêm http://eitguide.com/luu-tru-du-lieu-voi-shared-preferences-trong-android/

đây là code đọc file txt từ thư mục asset:

private static final String ADS_FILE = “ads_host.txt”;
private static final String WHITELIST_FILE = “whitelist_host.txt”;
private static final Set ADS_HOSTS = new HashSet<>();
private static final Set WHITELIST_HOSTS = new HashSet<>();

private Context mContext;

Host(Context context) {
    mContext = context;
    if (ADS_HOSTS.isEmpty()) {
        loadHosts(context, ADS_HOSTS, ADS_FILE);
    }

    if (WHITELIST_HOSTS.isEmpty()) {
        loadHosts(context, WHITELIST_HOSTS, WHITELIST_FILE);
    }
}

private static void loadHosts(final Context context, final Set<String> hosts, final String fileName) {
    Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {
            AssetManager manager = context.getAssets();
            try {
                BufferedReader reader = new BufferedReader(new InputStreamReader(manager.open(fileName)));
                String line;
                while ((line = reader.readLine()) != null) {
                    hosts.add(line.toLowerCase(AppConstants.LOCALE));
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    });
    thread.start();
}
1 Like

thanks you anh very much :slight_smile: :slight_smile:

em có mà anh

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?