2012-07-14 20 views
7

tôi muốn nhận tất cả hình ảnh/hình ảnh/hình nền từ thiết bị Android của tôi với đường dẫn hình ảnh đã lưu.làm thế nào để có được tất cả hình ảnh và hình ảnh từ thiết bị Android của tôi không phải từ sdcard?

tôi đã triển khai mã cho thu thập các hình ảnh từ sdcard như sau:

String[] mProjection = { 
    MediaStore.Images.Media._ID, 
    MediaStore.Images.Media.DATA 
}; 

mCursor = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, 
    mProjection, 
    null, 
    null, 
    MediaStore.Images.Media.DEFAULT_SORT_ORDER); 

từ đoạn mã trên tôi có thể có khả năng truy xuất hình ảnh từ sdcard only.But nếu những hình ảnh có sẵn trong bộ nhớ điện thoại thiết bị sau đó làm thế nào tôi có thể lấy lại hình ảnh/hình ảnh/hình nền? Nếu tôi sử dụng INTERNAL_CONTENT_URI nó không được trở về thông tin wallapers hình ảnh khác thông tin

vui lòng bất cứ cơ thể giúp tôi ....

+1

Bạn có chắc chắn có là ' hình nền 'hình ảnh (hoặc bất kỳ hình ảnh khác) được lưu trữ trong bộ nhớ trong có thể truy cập bởi ứng dụng của bạn? Nếu bạn sử dụng 'INTERNAL_CONTENt_URI', nó có trả về gì không? – Squonk

+0

http://stackoverflow.com/questions/7887078/android-saving-file-to-external-storage/7887114#7887114 – NagarjunaReddy

+0

xem xét vấn đề này http://stackoverflow.com/questions/10370188/issue-with -reading-file-from-internal-memory http://stackoverflow.com/questions/10378895/android-download-doc-pdf-from-the-internet-and-save-to-internal-memory http: // stackoverflow .com/questions/7674784/xóa-tệp-trong-bộ nhớ trong-từ-android-thiết bị http://stackoverflow.com/questions/9306155/writing-reading-files-to-from-android-phones-internal- Tôi hy vọng bất kỳ truy vấn nào từ điều này sẽ hữu ích cho bạn – Aamirkhan

Trả lời

0

Hãy thử giải vấn đề này sẽ làm việc:

public static final int GALLERY_CODE = 322; 

Intent intent = new Intent(); 
intent.setType("image/*"); 
intent.setAction(Intent.ACTION_GET_CONTENT); 
startActivityForResult(Intent.createChooser(
    intent, 
    "Select Picture"), 
    GALLERY_CODE); 


@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
//Assinging on corresponding import 
super.onActivityResult(requestCode, resultCode, data); 

    if (requestCode == GALLERY_CODE && resultCode == RESULT_OK) { 
     Uri selectedImageUri = data.getData(); 
     selectedImagePath = getPath(selectedImageUri); 

     try { 

      //add logic for coping file 

     } catch (Exception e) { 
     } 
    } 
} 

public String getPath(Uri uri) { 
    String[] projection = { MediaStore.Images.Media.DATA }; 
    Cursor cursor = managedQuery(uri, projection, null, null, null); 

    int column_index = cursor 
     .getColumnIndexOrThrow(MediaStore.Images.Media.DATA); 

    cursor.moveToFirst(); 
    return cursor.getString(column_index); 
} 
Các vấn đề liên quan