Layer-edge device of two-dimensional hybrid perovskites