get the image paths

This commit is contained in:
tibbi 2016-02-16 22:57:53 +01:00
parent e48d655298
commit 3cafb49996
3 changed files with 22 additions and 1 deletions

View File

@ -3,6 +3,8 @@
package="gallery.simplemobiletools.com"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"

View File

@ -1,6 +1,10 @@
package gallery.simplemobiletools.com;
import android.content.ContentResolver;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
@ -9,5 +13,20 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getImages();
}
private void getImages() {
final ContentResolver contentResolver = getContentResolver();
final Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
final Cursor cursor = contentResolver.query(uri, null, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
final int pathIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
do {
final String path = cursor.getString(pathIndex);
} while (cursor.moveToNext());
cursor.close();
}
}
}

View File

@ -1,3 +1,3 @@
<resources>
<string name="app_name">Simple-Gallery</string>
<string name="app_name">Simple Gallery</string>
</resources>