I'm sorry about probably posting a question similar to many others but I cannot find a solution to this or find a similar situation to where this error occurs. I have googled and googled all week trying to find an answer to this but not luck as of yet. I'm fairly new to android so if it is obvious, this is probably why!
These are the steps leading to the error:
The app uses the camera to take a picture
This image is then stored in a folder on the SDCard
A copy of this file is made and compressed down to 50-100kb per image (this is what I'm trying to display)
I then store the initial size and file name of the image in a sqlite database
when the activity (onResume I do this) is loaded
If there are any file names in the database, it gets the file name and displays the image - this is where the error is.
if(c.getCount() > 0) {
String[] cols = new String[] {DBAdapter.FILENAME,DBAdapter.DATETIME};
int[] values = new int[] {R.id.thumbnail,R.id.datetime_stamp};
SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(this, R.layout.image_listview, c, cols, values, 0);
ListView listView = (ListView) findViewById(android.R.id.list);
listView.setAdapter(cursorAdapter);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> listView, View view, int position, long id) {
String row = c.getString(c.getColumnIndexOrThrow(DBAdapter.KEY_ID)); // row ID from transactions
Toast.makeText(getBaseContext(), row, Toast.LENGTH_SHORT).show();
}
});
}
I am obviously missing something but its just driving me crazy!
The errors I'm getting if any of this helps are:
06-13 22:17:25.269: E/AndroidRuntime(24153): FATAL EXCEPTION: main
06-13 22:17:25.269: E/AndroidRuntime(24153): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:511)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:325)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:350)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.graphics.drawable.Drawable.createFromPath(Drawable.java:831)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.widget.ImageView.resolveUri(ImageView.java:573)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.widget.ImageView.setImageURI(ImageView.java:350)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.support.v4.widget.SimpleCursorAdapter.setViewImage(SimpleCursorAdapter.java:197)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.support.v4.widget.SimpleCursorAdapter.bindView(SimpleCursorAdapter.java:143)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.support.v4.widget.CursorAdapter.getView(CursorAdapter.java:256)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.widget.AbsListView.obtainView(AbsListView.java:1451)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.widget.ListView.makeAndAddView(ListView.java:1786)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.widget.ListView.fillDown(ListView.java:705)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.widget.ListView.fillGap(ListView.java:676)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.widget.AbsListView.trackMotionScroll(AbsListView.java:3579)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.widget.AbsListView.onTouchEvent(AbsListView.java:2294)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.widget.ListView.onTouchEvent(ListView.java:3493)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.view.View.dispatchTouchEvent(View.java:3935)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:934)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:973)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:973)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:973)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:973)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:973)
06-13 22:17:25.269: E/AndroidRuntime(24153): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1741)
06-13 22:17:25.269: E/AndroidRuntime(24153): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1172)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.app.Activity.dispatchTouchEvent(Activity.java:2135)
06-13 22:17:25.269: E/AndroidRuntime(24153): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1725)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2241)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.view.ViewRoot.handleMessage(ViewRoot.java:1925)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.os.Handler.dispatchMessage(Handler.java:130)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.os.Looper.loop(SourceFile:351)
06-13 22:17:25.269: E/AndroidRuntime(24153): at android.app.ActivityThread.main(ActivityThread.java:3814)
06-13 22:17:25.269: E/AndroidRuntime(24153): at java.lang.reflect.Method.invokeNative(Native Method)
06-13 22:17:25.269: E/AndroidRuntime(24153): at java.lang.reflect.Method.invoke(Method.java:538)
06-13 22:17:25.269: E/AndroidRuntime(24153): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
06-13 22:17:25.269: E/AndroidRuntime(24153): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:659)
06-13 22:17:25.269: E/AndroidRuntime(24153): at dalvik.system.NativeStart.main(Native Method)
Thanks in advance for any help.