Our question is about a listview that uses a recyclerview and is interfaced with a RecyclerAdapter. The ListView will show the data on both the device and emulator.
The problem is with the device Samsung SM-T810 with Android 7 APK 24 installed
the ListView shows once but if you close the app and restart the ListView no longer show. On the emulator Nexus 5X target & compile SDK 27 min SDK 19 if you close the app and restart the ListView is reloaded and shows data just fine
So the question is this an issue with the code or with the REAL device ?
We have checked with DBBrowser and the information is in the listview data is in the appropriate table
We will post the code below
public class TableListView extends AppCompatActivity {
DBHelper dbHelper = new DBHelper(this);
RecyclerView mRecyclerView;
private static RecyclerView.Adapter mAdapter;
private RecyclerView.LayoutManager mLayoutManager;
LinearLayout firstLL;
LinearLayout mainLL;
TextView tvNoData;
static final int READ_BLOCK_SIZE = 100;
static String stringREAD;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_table_list_view);
setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
firstLL = findViewById(R.id.firstLL);
mainLL = findViewById(R.id.mainLL);
tvNoData = findViewById(R.id.tvNoData);
readFROM_TEXT_FILE();
dbHelper = new DBHelper(this);
List<TableModel> dbTTList;
dbTTList = dbHelper.getDataFrom_TABLE_TRACKER();
int sz = dbTTList.size();
if(stringREAD.equals("EXTERNAL") || stringREAD.equals("INTERNAL") && sz == 0){
System.out.println("################ SIZE top "+sz);
tvNoData.setVisibility(View.VISIBLE);
tvNoData.setText("No Data Found\n\nClick On Manage Tables");
mRecyclerView = findViewById(R.id.recycleview);
mRecyclerView.setHasFixedSize(true);
mLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mLayoutManager);
mAdapter = new TableTrackerAdapter(this,dbTTList);
mRecyclerView.setAdapter(mAdapter);
}
if(stringREAD.equals("EXTERNAL") || stringREAD.equals("INTERNAL") && sz > 0){
System.out.println("################ SIZE bot "+sz);
mRecyclerView = findViewById(R.id.recycleview);
mRecyclerView.setHasFixedSize(true);
mLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mLayoutManager);
mAdapter = new TableTrackerAdapter(this,dbTTList);
mRecyclerView.setAdapter(mAdapter);
tvNoData.setVisibility(View.INVISIBLE);
}
setTitle("");// This sets the title of the toolbar
Toolbar topToolBar = findViewById(R.id.toolbar);
setSupportActionBar(topToolBar);
addListenerOnButtonAdd();
if (Build.VERSION.SDK_INT >= 23) {
if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
} else {
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 666); // Comment 26
}
}
}// END onCreate