public class Go extends AppCompatActivity {

private ListView listviewGo;
private ListGoAdapter adapter;
private List<GoItem> mGoItemList;
private GoDatabaseHelper mDBHelper;
private SearchView searchtext;

@Override
protected void onCreate(Bundle savedInstanceState) {
searchtext = (SearchView) findViewById(R.id.search_text);
super.onCreate(savedInstanceState);
setContentView(R.layout.go_layout);
listviewGo = (ListView)findViewById(R.id.listview_gotable);
mDBHelper = new GoDatabaseHelper(this);


File database = getApplicationContext().getDatabasePath(GoDatabaseHelper.DBName);
if (false == database.exists()){
mDBHelper.getReadableDatabase();
if(copyDatabase(this)){
Toast.makeText(this, "Copy Storage Success",Toast.LENGTH_SHORT).show();

}else{
Toast.makeText(this, "Copy Data Failed", Toast.LENGTH_SHORT).show();
return;
}
}

mGoItemList = mDBHelper.getListGo();
adapter = new ListGoAdapter(this, mGoItemList);
listviewGo.setAdapter(adapter);

listviewGo.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent inte = new Intent("com.apk.foodanalyzer.healthandnutrifactsanalyzer.Glow");// this is test to try if the setonitemclick listener is working but it doesn't
startActivity(inte);
}
});//when i click one item the intent was not executed.

}


private boolean copyDatabase(Context context){
try{

InputStream inputStream = context.getAssets().open(GoDatabaseHelper.DBName);
String outFileName = GoDatabaseHelper.DBLocation + GoDatabaseHelper.DBName;
OutputStream outputStream = new FileOutputStream(outFileName);
byte[]buff = new byte[1024];
int length = 0;
while((length = inputStream.read(buff)) > 0){
outputStream.write(buff,0,length);
}
outputStream.flush();
outputStream.close();
Log.v("GO TABLE","Database Copied Successfully");
return true;
}catch (Exception e){
e.printStackTrace();
return false;
}
}

}