行太大,无法放入游标窗口

时间:2019-11-11 00:15:48

标签: android sql

我正在存储一个PNG文件,该文件将转换为位图,然后将其转换为Byte []并存储MySQL数据库。

当我尝试在数据库中调用Item时,出现以下错误。

  

E / SQLiteQuery:例外:行太大,无法容纳CursorWindow requiredPos = 0,totalRows = 1;查询:SELECT * FROM myTable

     

原因:android.database.sqlite.SQLiteBlobTooBigException:行太大,无法容纳CursorWindow requiredPos = 0,totalRows = 1

有没有一种方法可以增加Cursor窗口的大小以接受字节[]?

@Dao
public interface MyDAO {

    @Query("SELECT * FROM myTable")
    LiveData<List<MyEntity>>getAllImages();
public class MyRepository {

    private MyDAO mMyDao;
    private LiveData<List<MyEntity>> mList;

    public MyRepository(Application application) {
        MyDatabase db = MyDatabase.getInstance(application);
        this.mMyDao = db.mMyDao();
        mList = mMyDao.getAllImages();
    }

    public LiveData<List<MyEntity>> getAllImages(){
        return mList;
    }

import java.util.List;

public class MainViewModel extends AndroidViewModel {

    private MyRepository mRepository;
    private LiveData<List<MyEntity>> mList;

    public MainViewModel(Application application) {
        super(application);
        mRepository = new MyRepository(application);
        mList = mRepository.getAllImages();
    }

    public LiveData<List<MyEntity>> getList() {
        return mList;
    }
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final MainViewModel myViewModel = ViewModelProviders.of(this).get(MainViewModel.class);


        Button btnLog = findViewById(R.id.btn_log);
        btnLog.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.d("MyLog", "update Log");
                myViewModel.getList().observe(MainActivity.this, new Observer<List<MyEntity>>() {
                    @Override
                    public void onChanged(List<MyEntity> myEntities) {

                        int listSize = myEntities.size();
                        Log.d("MyLog", "LiseSize " + listSize);
                        for(int i = 0; i < listSize; i++) {
                            Log.d("MyLog", "MyID " + myEntities.get(i).getID() +
                                    ", bitmap " + myEntities.get(i).getPHOTO());
                        }
                    }
                });
            }
        });

我期待在日志猫中看到字节[]

0 个答案:

没有答案