【发布时间】:2021-11-07 20:08:19
【问题描述】:
这段代码有什么问题,因为当我在设备中打开应用程序时,应用程序会崩溃
private void insertWhereAreYou() {
String firstNameString = mFirstName.getText().toString().trim();
String lastNameString = mLastName.getText().toString().trim();
String ageString = mAge.getText().toString().trim();
String descriptionString = mDescription.getText().toString().trim();
byte[] image = imageViewToByte(mInsertImage);
int age = Integer.parseInt(ageString);
ContentValues values = new ContentValues();
values.put(WhereAreYouEntry.COLUMN_FIRST_NAME, firstNameString);
values.put(WhereAreYouEntry.COLUMN_LAST_NAME, lastNameString);
values.put(WhereAreYouEntry.COLUMN_DESCRIPTION, descriptionString);
values.put(WhereAreYouEntry.COLUMN_AGE, age);
values.put(WhereAreYouEntry.COLUMN_IMAGE, image);
Uri newUri = getContentResolver().insert(WhereAreYouEntry.CONTENT_URI, values);
}
【问题讨论】:
-
你不能用 bye[] 设置ImageResource,我假设那里有一个位图(这本身有点奇怪,除非你从内容提供者而不是数据库中获取它),你有使用
BitmapFactory.decodeBitmap并在 imageview 上使用位图 -
你有别的解决办法吗,因为我用的是bindView
标签: java android android-studio