Source:
<code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.car_list); StoreConfig storeConfig = new StoreConfig(); storeConfig.setContext(getApplicationContext()); storeConfig.setType(StoreTypes.SQL); storeConfig.setKlass(Car.class); <START> idGenerator = new IncrementalIdGenerator(readLastSQLStoreIdFromSharedPreference()); <END> storeConfig.setIdGenerator(idGenerator); DataManager dataManager = new DataManager(); store = (SQLStore<Car>) dataManager.store("myStorage", storeConfig); store.open(new Callback<SQLStore<Car>>() { @Override public void onSuccess(SQLStore<Car> data) { updateDisplayCars(); } @Override public void onFailure(Exception e) { Toast.makeText(HowToUseSQLStorage.this, getString(R.string.error_open_database), Toast.LENGTH_SHORT).show(); } }); ListView listview = getListView(); listview.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long id) { final Car car = (Car) adapterView.getItemAtPosition(position); AlertDialog.Builder builder = new AlertDialog.Builder(HowToUseSQLStorage.this) .setTitle(getString(R.string.delete_confirmation)) .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { store.remove(car.getId()); updateDisplayCars(); } }) .setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); builder.create().show(); return false; } }); }</code><technical_language>this moved declaration</technical_language>

Target:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.car_list); idGenerator = new IncrementalIdGenerator(readLastSQLStoreIdFromSharedPreference()); StoreConfig storeConfig = buildStoreConfig(); DataManager dataManager = new DataManager(); store = (SQLStore<Car>) dataManager.store("myStorage", storeConfig); store.open(new Callback<SQLStore<Car>>() { @Override public void onSuccess(SQLStore<Car> data) { updateDisplayCars(); } @Override public void onFailure(Exception e) { Toast.makeText(HowToUseSQLStorage.this, getString(R.string.error_open_database), Toast.LENGTH_SHORT).show(); } }); ListView listview = getListView(); listview.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long id) { final Car car = (Car) adapterView.getItemAtPosition(position); AlertDialog.Builder builder = new AlertDialog.Builder(HowToUseSQLStorage.this) .setTitle(getString(R.string.delete_confirmation)) .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { remove(car); } }) .setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); builder.create().show(); return false; } }); }